From 63616582e9e229bfd4a6ebffa1a80b145ecec255 Mon Sep 17 00:00:00 2001 From: x620 Date: Thu, 5 May 2016 12:53:25 +0500 Subject: [PATCH 01/11] [IMP] add "Send message" button in the Sent menu --- mail_sent/static/src/js/sent.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index df2bc11..681ae22 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -16,6 +16,20 @@ var web_client = require('web.web_client'); var _lt = core._lt; //------------------------------------------------------------------------------- +var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); +ChatAction.include({ + set_channel: function(channel){ + var result = this._super.apply(this, arguments); + var self = this; + return $.when(result).done(function() { + // Add "Send message" button in the Sent menu + self.$buttons + .find('.o_mail_chat_button_new_message') + .toggle(channel.id === "channel_inbox" || channel.id === "channel_sent"); + }); + } +}); + // Inherit class and override methods base_obj.MailTools.include({ get_properties: function(msg){ From bcade8cd93e9fc09f5075b4124bcf336dad277d8 Mon Sep 17 00:00:00 2001 From: x620 Date: Thu, 5 May 2016 13:45:12 +0500 Subject: [PATCH 02/11] [FIX] show subject in channel_sent and channel_archive --- mail_archives/static/src/js/archives.js | 9 +++++++++ mail_sent/static/src/js/sent.js | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/mail_archives/static/src/js/archives.js b/mail_archives/static/src/js/archives.js index 912523a..fab77c9 100644 --- a/mail_archives/static/src/js/archives.js +++ b/mail_archives/static/src/js/archives.js @@ -16,6 +16,15 @@ var web_client = require('web.web_client'); var _lt = core._lt; //------------------------------------------------------------------------------- +var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); +ChatAction.include({ + get_thread_rendering_options: function (messages) { + var options = this._super.apply(this, arguments); + options.display_subject = options.display_subject || this.channel.id === "channel_archive"; + return options; + } +}); + // Inherit class and override methods base_obj.MailTools.include({ get_properties: function(msg){ diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index 681ae22..40be2c3 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -27,6 +27,11 @@ ChatAction.include({ .find('.o_mail_chat_button_new_message') .toggle(channel.id === "channel_inbox" || channel.id === "channel_sent"); }); + }, + get_thread_rendering_options: function (messages) { + var options = this._super.apply(this, arguments); + options.display_subject = options.display_subject || this.channel.id === "channel_sent"; + return options; } }); From 2326b5df6d86956437300ef30efad42e8f5e1670 Mon Sep 17 00:00:00 2001 From: x620 Date: Thu, 5 May 2016 15:31:46 +0500 Subject: [PATCH 03/11] [FIX] remove unused depends [DOC] change module description --- mail_archives/README.rst | 4 ++-- mail_archives/__openerp__.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mail_archives/README.rst b/mail_archives/README.rst index 56bd506..0395c12 100644 --- a/mail_archives/README.rst +++ b/mail_archives/README.rst @@ -1,11 +1,11 @@ Mail Archives ============= -Adds Archive menu, which shows all messages +Adds Archive menu, which shows sent/received messages Usage ----- -Click Discuss/Archive menu -- all messages are displayed +Click Discuss/Archive menu -- sent/received messages are displayed Further information ------------------- diff --git a/mail_archives/__openerp__.py b/mail_archives/__openerp__.py index 57c4508..5995e02 100644 --- a/mail_archives/__openerp__.py +++ b/mail_archives/__openerp__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- { "name": "Mail archives", - "summary": """Adds menu to find old messages""", + "summary": """Adds menu to find sent/received messages""", "category": "Discuss", "images": [], "version": "1.0.0", @@ -13,8 +13,6 @@ 'currency': 'EUR', "depends": [ - "base", - "mail", "mail_base" ], From e8310c841b8fa3c23333e9e5c3c830d0b7292dd0 Mon Sep 17 00:00:00 2001 From: x620 Date: Thu, 5 May 2016 17:28:19 +0500 Subject: [PATCH 04/11] [FIX] change way for show "Send message" button --- mail_base/static/src/js/base.js | 4 ++++ mail_sent/static/src/js/sent.js | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index 7e7549f..b578d14 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -63,6 +63,10 @@ var channel_seen = _.throttle(function (channel) { var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ + init: function(parent, action, options) { + this._super.apply(this, arguments); + this.show_send_message_button = ['channel_inbox']; + }, start: function() { var result = this._super.apply(this, arguments); diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index 40be2c3..dd311fa 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -20,12 +20,13 @@ var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ set_channel: function(channel){ var result = this._super.apply(this, arguments); + // Add "Send message" button in the Sent menu + this.show_send_message_button.push('channel_sent'); var self = this; return $.when(result).done(function() { - // Add "Send message" button in the Sent menu self.$buttons .find('.o_mail_chat_button_new_message') - .toggle(channel.id === "channel_inbox" || channel.id === "channel_sent"); + .toggle(self.show_send_message_button.includes(channel.id)); }); }, get_thread_rendering_options: function (messages) { From 1dc49ee7fd912f8fd79327fb80db9d2a78bbf81a Mon Sep 17 00:00:00 2001 From: x620 Date: Thu, 5 May 2016 18:00:03 +0500 Subject: [PATCH 05/11] [FIX] change function from .includes() to .indexOf() --- mail_sent/static/src/js/sent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index dd311fa..a31d6fe 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -26,7 +26,7 @@ ChatAction.include({ return $.when(result).done(function() { self.$buttons .find('.o_mail_chat_button_new_message') - .toggle(self.show_send_message_button.includes(channel.id)); + .toggle(self.show_send_message_button.indexOf(channel.id) != -1); }); }, get_thread_rendering_options: function (messages) { From 971ba44447898f1ba31a662025776ef1fbda3c99 Mon Sep 17 00:00:00 2001 From: x620 Date: Thu, 5 May 2016 18:22:59 +0500 Subject: [PATCH 06/11] [FIX] move function toggle() from sent.js to base.js [FIX] change summary in __openerp__.py --- mail_archives/__openerp__.py | 2 +- mail_base/static/src/js/base.js | 9 +++++++++ mail_sent/static/src/js/sent.js | 10 ++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mail_archives/__openerp__.py b/mail_archives/__openerp__.py index 5995e02..30d9a94 100644 --- a/mail_archives/__openerp__.py +++ b/mail_archives/__openerp__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- { "name": "Mail archives", - "summary": """Adds menu to find sent/received messages""", + "summary": """Adds menu to find old messages""", "category": "Discuss", "images": [], "version": "1.0.0", diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index b578d14..12f1111 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -97,6 +97,15 @@ ChatAction.include({ } }); return result; + }, + set_channel: function(channel){ + var result = this._super.apply(this, arguments); + var self = this; + return $.when(result).done(function() { + self.$buttons + .find('.o_mail_chat_button_new_message') + .toggle(self.show_send_message_button.indexOf(channel.id) != -1); + }); } }); diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index a31d6fe..c84de74 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -19,15 +19,9 @@ var _lt = core._lt; var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ set_channel: function(channel){ - var result = this._super.apply(this, arguments); - // Add "Send message" button in the Sent menu + this._super.apply(this, arguments); + // Add channel Sent for show "Send message" button this.show_send_message_button.push('channel_sent'); - var self = this; - return $.when(result).done(function() { - self.$buttons - .find('.o_mail_chat_button_new_message') - .toggle(self.show_send_message_button.indexOf(channel.id) != -1); - }); }, get_thread_rendering_options: function (messages) { var options = this._super.apply(this, arguments); From dc9a9c973d936f6a823efc110622ee8eccfbf810 Mon Sep 17 00:00:00 2001 From: x620 Date: Thu, 5 May 2016 18:44:01 +0500 Subject: [PATCH 07/11] [FIX] move function push() from set_channel() to init() to push() is called only once --- mail_sent/static/src/js/sent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index c84de74..b5490ea 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -18,7 +18,7 @@ var _lt = core._lt; var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ - set_channel: function(channel){ + init: function(parent, action, options) { this._super.apply(this, arguments); // Add channel Sent for show "Send message" button this.show_send_message_button.push('channel_sent'); From c67b8c22f3a20627003cde99b04c168569c0dc3b Mon Sep 17 00:00:00 2001 From: x620 Date: Fri, 6 May 2016 13:14:27 +0500 Subject: [PATCH 08/11] [IMP] change mail_archive module for show only sent/recipient messages --- mail_archives/__init__.py | 2 -- mail_archives/__openerp__.py | 2 +- mail_archives/models/__init__.py | 1 - mail_archives/static/src/js/archives.js | 21 +++++++++++++++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) delete mode 100644 mail_archives/models/__init__.py diff --git a/mail_archives/__init__.py b/mail_archives/__init__.py index 5305644..40a96af 100644 --- a/mail_archives/__init__.py +++ b/mail_archives/__init__.py @@ -1,3 +1 @@ # -*- coding: utf-8 -*- - -from . import models \ No newline at end of file diff --git a/mail_archives/__openerp__.py b/mail_archives/__openerp__.py index 30d9a94..737e949 100644 --- a/mail_archives/__openerp__.py +++ b/mail_archives/__openerp__.py @@ -13,7 +13,7 @@ 'currency': 'EUR', "depends": [ - "mail_base" + "mail_sent", ], "data": [ diff --git a/mail_archives/models/__init__.py b/mail_archives/models/__init__.py deleted file mode 100644 index 40a96af..0000000 --- a/mail_archives/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/mail_archives/static/src/js/archives.js b/mail_archives/static/src/js/archives.js index fab77c9..436e55e 100644 --- a/mail_archives/static/src/js/archives.js +++ b/mail_archives/static/src/js/archives.js @@ -35,7 +35,20 @@ base_obj.MailTools.include({ set_channel_flags: function(data, msg){ this._super.apply(this, arguments); - msg.is_archive = true; + // Get recipients ids + var recipients_ids = []; + for (var i = 0; i < data.partner_ids.length; i++){ + recipients_ids.push(data.partner_ids[i][0]); + } + + // If author or recipient + if ( + (data.sent && data.author_id[0] == session.partner_id) + || (recipients_ids.indexOf(session.partner_id) != -1) + ) { + msg.is_archive = true; + } + return msg; }, @@ -45,7 +58,11 @@ base_obj.MailTools.include({ }, get_domain: function(channel){ - return (channel.id === "channel_archive") ? [] : this._super.apply(this, arguments); + return (channel.id === "channel_archive") ? [ + '|', ['partner_ids', 'in', [openerp.session.partner_id]], + '&', ['sent', '=', true], + ['author_id.user_ids', 'in', [openerp.session.uid]] + ] : this._super.apply(this, arguments); } }); From 4004e007c1c8236b8b96f67a4298a3a55b9e57c8 Mon Sep 17 00:00:00 2001 From: x620 Date: Fri, 6 May 2016 13:54:08 +0500 Subject: [PATCH 09/11] [FIX] remove depends on the mail_sent --- mail_archives/__openerp__.py | 2 +- mail_archives/static/src/js/archives.js | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/mail_archives/__openerp__.py b/mail_archives/__openerp__.py index 737e949..761bb6b 100644 --- a/mail_archives/__openerp__.py +++ b/mail_archives/__openerp__.py @@ -13,7 +13,7 @@ 'currency': 'EUR', "depends": [ - "mail_sent", + "mail_base", ], "data": [ diff --git a/mail_archives/static/src/js/archives.js b/mail_archives/static/src/js/archives.js index 436e55e..3640a2c 100644 --- a/mail_archives/static/src/js/archives.js +++ b/mail_archives/static/src/js/archives.js @@ -42,10 +42,7 @@ base_obj.MailTools.include({ } // If author or recipient - if ( - (data.sent && data.author_id[0] == session.partner_id) - || (recipients_ids.indexOf(session.partner_id) != -1) - ) { + if (data.author_id[0] == session.partner_id || recipients_ids.indexOf(session.partner_id) != -1) { msg.is_archive = true; } @@ -60,7 +57,6 @@ base_obj.MailTools.include({ get_domain: function(channel){ return (channel.id === "channel_archive") ? [ '|', ['partner_ids', 'in', [openerp.session.partner_id]], - '&', ['sent', '=', true], ['author_id.user_ids', 'in', [openerp.session.uid]] ] : this._super.apply(this, arguments); } From 723b3cd6e6f68796873c4285a35ee0ec527316c2 Mon Sep 17 00:00:00 2001 From: x620 Date: Fri, 6 May 2016 17:33:45 +0500 Subject: [PATCH 10/11] [REF] Create channels_display_subject array which will contain channels name for subject display. get_thread_rendering_options() method moved in base.js. In new modules append channel name to channels_display_subject variable for enable subject display. --- mail_archives/static/src/js/archives.js | 9 +++++---- mail_base/static/src/js/base.js | 6 ++++++ mail_sent/static/src/js/sent.js | 10 ++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mail_archives/static/src/js/archives.js b/mail_archives/static/src/js/archives.js index 3640a2c..a494961 100644 --- a/mail_archives/static/src/js/archives.js +++ b/mail_archives/static/src/js/archives.js @@ -18,10 +18,11 @@ var _lt = core._lt; var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ - get_thread_rendering_options: function (messages) { - var options = this._super.apply(this, arguments); - options.display_subject = options.display_subject || this.channel.id === "channel_archive"; - return options; + init: function(parent, action, options) { + this._super.apply(this, arguments); + var channel_name = 'channel_archive'; + // Add channel Archive for enable "display_subject" option + this.channels_display_subject.push(channel_name); } }); diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index 12f1111..653a810 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -66,6 +66,7 @@ ChatAction.include({ init: function(parent, action, options) { this._super.apply(this, arguments); this.show_send_message_button = ['channel_inbox']; + this.channels_display_subject = []; }, start: function() { var result = this._super.apply(this, arguments); @@ -106,6 +107,11 @@ ChatAction.include({ .find('.o_mail_chat_button_new_message') .toggle(self.show_send_message_button.indexOf(channel.id) != -1); }); + }, + get_thread_rendering_options: function (messages) { + var options = this._super.apply(this, arguments); + options.display_subject = options.display_subject || this.channels_display_subject.indexOf(this.channel.id) != -1; + return options; } }); diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index b5490ea..7eadfa3 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -20,13 +20,11 @@ var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ init: function(parent, action, options) { this._super.apply(this, arguments); + var channel_name = 'channel_sent'; // Add channel Sent for show "Send message" button - this.show_send_message_button.push('channel_sent'); - }, - get_thread_rendering_options: function (messages) { - var options = this._super.apply(this, arguments); - options.display_subject = options.display_subject || this.channel.id === "channel_sent"; - return options; + this.show_send_message_button.push(channel_name); + // Add channel Sent for enable "display_subject" option + this.channels_display_subject.push(channel_name); } }); From 3218b251cc3ce3437bebb89a86db83663bfa96e9 Mon Sep 17 00:00:00 2001 From: x620 Date: Fri, 6 May 2016 17:58:17 +0500 Subject: [PATCH 11/11] [REF] rename show_send_message_button variable to channels_show_send_button --- mail_base/static/src/js/base.js | 4 ++-- mail_sent/static/src/js/sent.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index 653a810..332fe34 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -65,7 +65,7 @@ var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ init: function(parent, action, options) { this._super.apply(this, arguments); - this.show_send_message_button = ['channel_inbox']; + this.channels_show_send_button = ['channel_inbox']; this.channels_display_subject = []; }, start: function() { @@ -105,7 +105,7 @@ ChatAction.include({ return $.when(result).done(function() { self.$buttons .find('.o_mail_chat_button_new_message') - .toggle(self.show_send_message_button.indexOf(channel.id) != -1); + .toggle(self.channels_show_send_button.indexOf(channel.id) != -1); }); }, get_thread_rendering_options: function (messages) { diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index 7eadfa3..1a3c298 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -22,7 +22,7 @@ ChatAction.include({ this._super.apply(this, arguments); var channel_name = 'channel_sent'; // Add channel Sent for show "Send message" button - this.show_send_message_button.push(channel_name); + this.channels_show_send_button.push(channel_name); // Add channel Sent for enable "display_subject" option this.channels_display_subject.push(channel_name); }