From b6cd43bf45a5643952889ea65c74a8a542bd3558 Mon Sep 17 00:00:00 2001 From: x620 Date: Mon, 4 Apr 2016 18:42:18 +0500 Subject: [PATCH 01/10] [DOC] __openerp__.py - change category, README.rst - change name menu item --- mail_archives/README.rst | 2 +- mail_archives/__openerp__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mail_archives/README.rst b/mail_archives/README.rst index 3b2d013..56bd506 100644 --- a/mail_archives/README.rst +++ b/mail_archives/README.rst @@ -5,7 +5,7 @@ Adds Archive menu, which shows all messages Usage ----- -Click Messaing/Arhive menu -- all messages are displayed +Click Discuss/Archive menu -- all messages are displayed Further information ------------------- diff --git a/mail_archives/__openerp__.py b/mail_archives/__openerp__.py index 8ecce36..ff316df 100644 --- a/mail_archives/__openerp__.py +++ b/mail_archives/__openerp__.py @@ -2,7 +2,7 @@ { "name": "mail_archives", "summary": """Create archive channel""", - "category": "Uncategorized", + "category": "Discuss", "images": [], "version": "1.0.0", From ad9462c0f5e5ead8b0f0b1dba1f747e9913b1fb6 Mon Sep 17 00:00:00 2001 From: x620 Date: Mon, 4 Apr 2016 18:46:45 +0500 Subject: [PATCH 02/10] [ADD] Create module Mail Sent and added changes that displayed Sent menu item --- mail_sent/README.rst | 15 +++++++ mail_sent/__init__.py | 3 ++ mail_sent/__openerp__.py | 26 ++++++++++++ mail_sent/models/__init__.py | 1 + mail_sent/static/description/icon.png | Bin 0 -> 2140 bytes mail_sent/static/src/js/sent.js | 56 ++++++++++++++++++++++++++ mail_sent/static/src/xml/menu.xml | 20 +++++++++ mail_sent/views/templates.xml | 12 ++++++ 8 files changed, 133 insertions(+) create mode 100644 mail_sent/README.rst create mode 100644 mail_sent/__init__.py create mode 100644 mail_sent/__openerp__.py create mode 100644 mail_sent/models/__init__.py create mode 100644 mail_sent/static/description/icon.png create mode 100644 mail_sent/static/src/js/sent.js create mode 100644 mail_sent/static/src/xml/menu.xml create mode 100644 mail_sent/views/templates.xml diff --git a/mail_sent/README.rst b/mail_sent/README.rst new file mode 100644 index 0000000..41662b5 --- /dev/null +++ b/mail_sent/README.rst @@ -0,0 +1,15 @@ +Mail Sent +========= + +Adds Sent menu, which shows sent messages + +Usage +----- +Click Discuss/Sent menu -- sent messages are displayed + +Further information +------------------- + +HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_sent/ + +Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee \ No newline at end of file diff --git a/mail_sent/__init__.py b/mail_sent/__init__.py new file mode 100644 index 0000000..5305644 --- /dev/null +++ b/mail_sent/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models \ No newline at end of file diff --git a/mail_sent/__openerp__.py b/mail_sent/__openerp__.py new file mode 100644 index 0000000..4f1b75e --- /dev/null +++ b/mail_sent/__openerp__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +{ + "name": "Mail Sent", + "summary": """Create sent channel""", + "category": "Discuss", + "images": [], + "version": "1.0.0", + + "author": "IT-Projects LLC, Pavel Romanchenko", + "website": "https://it-projects.info", + "license": "LGPL-3", + + "depends": [ + "base", + "mail", + "mail_base" + ], + + "data": [ + "views/templates.xml", + ], + "qweb": [ + "static/src/xml/menu.xml", + ], + 'installable': True, +} diff --git a/mail_sent/models/__init__.py b/mail_sent/models/__init__.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/mail_sent/models/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/mail_sent/static/description/icon.png b/mail_sent/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..79f7d8fe294f838cf2996940c40dc08dde60642f GIT binary patch literal 2140 zcmV-i2&4CjP)=D+Wys1fe}G$Q#Z2832St25n<}h#$%L7sUBHn zgVlR~4gtNOs+KA#@5q|?_&of{fCW3h;+eI-@is^))^C>Ap=O06Yq-$?c7APo?&VKv z))(zizAhAwtYInZ&irDhM>SGBFM>?d${LzoxNVMo=er+dj|dVX82(itvPy&nJI7R} zxal|{b!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*MCY|fYs06&r)EvXweNU2#O3lwsaSN3LjB|<)5GbI&(^F8Ja$Saf5Dn zfe8N*NS_HTjLe(YbWiuKO3@!C&=suZc=@z@*Skh)DrGicOE-M=A%!7Zj9>aSC(&v#nWVj-o?-d4Br_8Z zDP85P;LTw*XT(K^Ln=~W$+dIA7^DnX@{`gzERF6PYOuNDqSwU8{M+dh76b)Z$^Np8 zK`L@#(IcfdSX4>r$FmU4GvlLe(Pp~uq7PD-^kM2p`;8cbRHVRCk`&s%0t^5+Kg1eL SSUIi$0000 + diff --git a/mail_sent/views/templates.xml b/mail_sent/views/templates.xml new file mode 100644 index 0000000..3e685e0 --- /dev/null +++ b/mail_sent/views/templates.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file From 9c18f6445a6950e90df958390f150c716df549be Mon Sep 17 00:00:00 2001 From: x620 Date: Tue, 5 Apr 2016 11:01:20 +0500 Subject: [PATCH 03/10] [FIX] sent.js correction for displayed sent page --- mail_sent/static/src/js/sent.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index 86813fb..13ddad6 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -1,4 +1,4 @@ -odoo.define('mail_archives.archives', function (require) { +odoo.define('mail_sent.sent', function (require) { "use strict"; var base_obj = require('mail_base.base'); @@ -20,7 +20,7 @@ var _t = core._t; base_obj.MailTools.include({ get_properties: function(msg){ var properties = this._super.apply(this, arguments); - properties.is_archive = this.property_descr("channel_archive", msg, this); + properties.is_archive = this.property_descr("channel_sent", msg, this); return properties; }, @@ -32,19 +32,19 @@ base_obj.MailTools.include({ get_channel_array: function(msg){ var arr = this._super.apply(this, arguments); - return arr.concat('channel_archive'); + return arr.concat('channel_sent'); }, get_domain: function(channel){ - return (channel.id === "channel_archive") ? [] : this._super.apply(this, arguments); + return (channel.id === "channel_sent") ? [] : this._super.apply(this, arguments); } }); base_obj.chat_manager.is_ready.then(function(){ // Add archive channel base_obj.chat_manager.mail_tools.add_channel({ - id: "channel_archive", - name: _t("Archive"), + id: "channel_sent", + name: _t("Sent"), type: "static" }); From 74fa3eda6a2209e05defb45c3b7f4f4a75977770 Mon Sep 17 00:00:00 2001 From: x620 Date: Wed, 6 Apr 2016 15:42:45 +0500 Subject: [PATCH 04/10] [FIX] sent.js correction set_channel_flags() and get_domain() methods for correct sent messages filtration [FIX] base.js correction "cls" to "chat_manager.mail_tools" [FIX] models.py correction _get_sent() method and remove outdated notification method [REF] menu.xml move "sent" menu item to after "inbox" menu item and change icon --- mail_base/static/src/js/base.js | 12 +++++----- mail_sent/__init__.py | 2 +- mail_sent/models.py | 26 ++++++++------------- mail_sent/models/__init__.py | 1 - mail_sent/static/src/js/sent.js | 13 +++++++---- mail_sent/static/src/xml/menu.xml | 4 ++-- mail_sent/views.xml | 38 ------------------------------- 7 files changed, 28 insertions(+), 68 deletions(-) delete mode 100644 mail_sent/models/__init__.py delete mode 100644 mail_sent/views.xml diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index dee2ae8..dbc5fa2 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -160,9 +160,9 @@ var MailTools = core.Class.extend({ _.each(msg.channel_ids, function (channel_id) { var channel = chat_manager.get_channel(channel_id); if (channel) { - cls.add_to_cache(msg, []); + chat_manager.mail_tools.add_to_cache(msg, []); if (options.domain && options.domain !== []) { - cls.add_to_cache(msg, options.domain); + chat_manager.mail_tools.add_to_cache(msg, options.domain); } if (channel.hidden) { channel.hidden = false; @@ -412,7 +412,7 @@ var MailTools = core.Class.extend({ _.each(message.channel_ids, function (channel_id) { var channel = chat_manager.get_channel(channel_id); if (channel) { - var channel_cache = cls.get_channel_cache(channel, domain); + var channel_cache = chat_manager.mail_tools.get_channel_cache(channel, domain); var index = _.sortedIndex(channel_cache.messages, message, 'id'); if (channel_cache.messages[index] !== message) { channel_cache.messages.splice(index, 0, message); @@ -586,12 +586,12 @@ var MailTools = core.Class.extend({ _.each(data.message_ids, function (msg_id) { var message = _.findWhere(messages, { id: msg_id }); if (message) { - cls.invalidate_caches(message.channel_ids); + chat_manager.mail_tools.invalidate_caches(message.channel_ids); message.is_starred = data.starred; if (!message.is_starred) { - cls.remove_message_from_channel("channel_starred", message); + chat_manager.mail_tools.remove_message_from_channel("channel_starred", message); } else { - cls.add_to_cache(message, []); + chat_manager.mail_tools.add_to_cache(message, []); var channel_starred = chat_manager.get_channel('channel_starred'); channel_starred.cache = _.pick(channel_starred.cache, "[]"); } diff --git a/mail_sent/__init__.py b/mail_sent/__init__.py index cde864b..c7b5ac7 100644 --- a/mail_sent/__init__.py +++ b/mail_sent/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -from . import models +import models diff --git a/mail_sent/models.py b/mail_sent/models.py index 38c82e9..16414ed 100644 --- a/mail_sent/models.py +++ b/mail_sent/models.py @@ -1,28 +1,22 @@ +# -*- coding: utf-8 -*- from openerp import api, models, fields -class mail_message(models.Model): +class MailMessage(models.Model): _inherit = 'mail.message' + sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True) + @api.one - @api.depends('author_id', 'notified_partner_ids') + @api.depends('author_id', 'partner_ids') def _get_sent(self): self_sudo = self.sudo() - self_sudo.sent = len(self_sudo.notified_partner_ids) > 1 or len(self_sudo.notified_partner_ids) == 1 and self_sudo.author_id and self_sudo.notified_partner_ids[0].id != self_sudo.author_id.id - - sent = fields.Boolean('Sent', compute=_get_sent, help='Was message sent to someone', store=True) - - -class mail_notification(models.Model): - _inherit = 'mail.notification' + self_sudo.sent = len(self_sudo.partner_ids) > 1 \ + or len(self_sudo.partner_ids) == 1 \ + and self_sudo.author_id \ + and self_sudo.partner_ids[0].id != self_sudo.author_id.id - def _notify(self, cr, uid, message_id, **kwargs): - super(mail_notification, self)._notify(cr, uid, message_id, **kwargs) - self.pool['mail.message'].browse(cr, uid, message_id)._get_sent() - - -class mail_compose_message(models.TransientModel): +class MailComposeMessage(models.TransientModel): _inherit = 'mail.compose.message' sent = fields.Boolean('Sent', help='dummy field to fix inherit error') - diff --git a/mail_sent/models/__init__.py b/mail_sent/models/__init__.py deleted file mode 100644 index 40a96af..0000000 --- a/mail_sent/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/mail_sent/static/src/js/sent.js b/mail_sent/static/src/js/sent.js index 13ddad6..8b1d0d6 100644 --- a/mail_sent/static/src/js/sent.js +++ b/mail_sent/static/src/js/sent.js @@ -20,13 +20,15 @@ var _t = core._t; base_obj.MailTools.include({ get_properties: function(msg){ var properties = this._super.apply(this, arguments); - properties.is_archive = this.property_descr("channel_sent", msg, this); + properties.is_sent = this.property_descr("channel_sent", msg, this); return properties; }, set_channel_flags: function(data, msg){ this._super.apply(this, arguments); - msg.is_archive = true; + if (_.contains(data.author_id, session.partner_id) && data.partner_ids.length > 0) { + msg.is_sent = true; + } return msg; }, @@ -36,12 +38,15 @@ base_obj.MailTools.include({ }, get_domain: function(channel){ - return (channel.id === "channel_sent") ? [] : this._super.apply(this, arguments); + return (channel.id === "channel_sent") ? [ + ['sent', '=', true], + ['author_id.user_ids', 'in', [openerp.session.uid]] + ] : this._super.apply(this, arguments); } }); base_obj.chat_manager.is_ready.then(function(){ - // Add archive channel + // Add sent channel base_obj.chat_manager.mail_tools.add_channel({ id: "channel_sent", name: _t("Sent"), diff --git a/mail_sent/static/src/xml/menu.xml b/mail_sent/static/src/xml/menu.xml index 799a379..de92e3a 100644 --- a/mail_sent/static/src/xml/menu.xml +++ b/mail_sent/static/src/xml/menu.xml @@ -2,9 +2,9 @@