From c2c40612b3dea8b52cdd6e328d5d88a13f164efb Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Wed, 25 Jan 2017 12:30:17 +0500 Subject: [PATCH 1/5] [REF][FIX] didn't work for non-admin users --- mail_sent/__openerp__.py | 2 +- mail_sent/doc/changelog.rst | 7 +++---- mail_sent/models.py | 17 +++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mail_sent/__openerp__.py b/mail_sent/__openerp__.py index a4c5609..734833a 100644 --- a/mail_sent/__openerp__.py +++ b/mail_sent/__openerp__.py @@ -4,7 +4,7 @@ "summary": """Quick way to find sent messages""", "category": "Discuss", "images": ['images/menu.png'], - "version": "1.0.3", + "version": "1.0.4", "author": "IT-Projects LLC, Ivan Yelizariev, Pavel Romanchenko", "website": "https://it-projects.info", diff --git a/mail_sent/doc/changelog.rst b/mail_sent/doc/changelog.rst index 2147d0e..142f071 100644 --- a/mail_sent/doc/changelog.rst +++ b/mail_sent/doc/changelog.rst @@ -1,7 +1,6 @@ -.. _changelog: - -Updates -======= +`1.0.4` +------- +- **FIX:** didn't work for non-admin users `1.0.2` ------- diff --git a/mail_sent/models.py b/mail_sent/models.py index 6e215e1..6d1ef14 100644 --- a/mail_sent/models.py +++ b/mail_sent/models.py @@ -5,16 +5,17 @@ from openerp import api, models, fields class MailMessage(models.Model): _inherit = 'mail.message' - sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True) + sent = fields.Boolean('Sent', compute="_compute_sent", help='Was message sent to someone', store=True) - @api.one @api.depends('author_id', 'partner_ids') - def _get_sent(self): - self_sudo = self.sudo() - 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 _compute_sent(self): + for r in self: + r_sudo = r.sudo() + sent = len(r_sudo.partner_ids) > 1 \ + or len(r_sudo.partner_ids) == 1 \ + and r_sudo.author_id \ + and r_sudo.partner_ids[0].id != r_sudo.author_id.id + r.sent = sent @api.multi def message_format(self): From 5cf4bf848148c7a758acd0d7dd1fec0a2c42558e Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Wed, 25 Jan 2017 14:28:35 +0500 Subject: [PATCH 2/5] [FIX] clear messages cache on sending message via Mail Composer. Otherwise Sent, Arhives menus will have new message until user refresh whole web page [DOC] refactoring in docs --- mail_base/README.rst | 23 ++++++++++++++++------- mail_base/__init__.py | 1 + mail_base/__openerp__.py | 2 +- mail_base/controllers/__init__.py | 1 + mail_base/controllers/main.py | 15 +++++++++++++++ mail_base/doc/changelog.rst | 9 +++++++++ mail_base/doc/index.rst | 4 ++++ mail_base/models.py | 13 +++++++++++++ mail_base/static/src/js/base.js | 14 ++++++++++++++ 9 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 mail_base/controllers/__init__.py create mode 100644 mail_base/controllers/main.py create mode 100644 mail_base/doc/changelog.rst create mode 100644 mail_base/doc/index.rst diff --git a/mail_base/README.rst b/mail_base/README.rst index 0aa46ac..9e936a2 100644 --- a/mail_base/README.rst +++ b/mail_base/README.rst @@ -6,14 +6,23 @@ Mail Base * fixes toggling left bar * fixes Recipients field. Out-of-box this field could be empty. -Usage ------ -To use this module you need either install module that depends on it or create new module. +One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js `__ + + // to do: move this to mail.utils + + + +Note. Due to odoo restrictions, module makes mail initialization again. That is browser loads emoji and other chat data twice. This is the only way to make Mail feature extendable. Further information -------------------- -Due to odoo restrictions, module makes mail initialization again. That is browser loads emoji and other chat data twice. This is the only way to make Mail feature extendable. +=================== -One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js `__ +Demo: http://runbot.it-projects.info/demo/mail-addons/9.0 - // to do: move this to mail.utils +.. HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_base/ + +Usage instructions: ``_ + +Changelog: ``_ + +Tested on Odoo 9.0 c8cd67c5d98b410cabe0a6efb3347a8a4de731d8 diff --git a/mail_base/__init__.py b/mail_base/__init__.py index cde864b..c3d410e 100644 --- a/mail_base/__init__.py +++ b/mail_base/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from . import models +from . import controllers diff --git a/mail_base/__openerp__.py b/mail_base/__openerp__.py index b9c9b6d..8f56427 100644 --- a/mail_base/__openerp__.py +++ b/mail_base/__openerp__.py @@ -4,7 +4,7 @@ "summary": """Makes Mail extendable""", "category": "Discuss", "images": [], - "version": "1.0.0", + "version": "1.0.1", "author": "IT-Projects LLC, Pavel Romanchenko", "website": "https://it-projects.info", diff --git a/mail_base/controllers/__init__.py b/mail_base/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/mail_base/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/mail_base/controllers/main.py b/mail_base/controllers/main.py new file mode 100644 index 0000000..8812df9 --- /dev/null +++ b/mail_base/controllers/main.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from openerp.http import request +import openerp + + +class MailChatController(openerp.addons.bus.controllers.main.BusController): + # ----------------------------- + # Extends BUS Controller Poll + # ----------------------------- + + def _poll(self, dbname, channels, last, options): + if request.session.uid: + channels.append((request.db, 'mail_base.mail_sent')) + + return super(MailChatController, self)._poll(dbname, channels, last, options) diff --git a/mail_base/doc/changelog.rst b/mail_base/doc/changelog.rst new file mode 100644 index 0000000..a42098f --- /dev/null +++ b/mail_base/doc/changelog.rst @@ -0,0 +1,9 @@ +`1.0.1` +------- + +- **FIX**: clear messages cache on sending message via Mail Composer. Otherwise Sent, Arhives menus will have new message until user refresh whole web page + +`1.0.0` +------- + +- Init version diff --git a/mail_base/doc/index.rst b/mail_base/doc/index.rst new file mode 100644 index 0000000..9f8b977 --- /dev/null +++ b/mail_base/doc/index.rst @@ -0,0 +1,4 @@ +Mail Base +========= + +To use this module you need either install module that depends on it or create new module. diff --git a/mail_base/models.py b/mail_base/models.py index ade9a35..953f49f 100644 --- a/mail_base/models.py +++ b/mail_base/models.py @@ -16,3 +16,16 @@ class MailMessage(models.Model): for id in triplet[2]: values['partner_ids'].append((4, id, False)) return super(MailMessage, self).write(values) + + +class MailComposer(models.TransientModel): + + _inherit = 'mail.compose.message' + + @api.multi + def send_mail(self, auto_commit=False): + res = super(MailComposer, self).send_mail(auto_commit=auto_commit) + notification = {} + self.env['bus.bus'].sendone((self._cr.dbname, 'mail_base.mail_sent'), notification) + + return res diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index 53c9f0e..a9d64ef 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -482,6 +482,12 @@ var MailTools = core.Class.extend({ }); }, + clear_cache_all_channels: function(){ + _.each(channels, function(channel){ + channel.cache = {}; + }) + }, + add_to_cache: function (message, domain) { _.each(message.channel_ids, function (channel_id) { var channel = chat_manager.get_channel(channel_id); @@ -616,6 +622,14 @@ var MailTools = core.Class.extend({ } else if (model === 'bus.presence') { // update presence of users chat_manager.mail_tools.on_presence_notification(notification[1]); + } else if (model === 'mail_base.mail_sent') { + // Delete cache in order to fetch new message + + // TODO find a solution without deleting cache. Currently + // problem is that on inheriting send_mail in + // mail.compose.message it's not possible to get id of new + // message + chat_manager.mail_tools.clear_cache_all_channels(); } }); }, From 0152ce87f92640f18ab7b05bbb81bae59270a79d Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Wed, 25 Jan 2017 15:40:23 +0500 Subject: [PATCH 3/5] [LINT] fix line breaks --- mail_archives/README.rst | 2 +- mail_archives/views/templates.xml | 2 +- mail_attachment_popup/static/lib/js/jquery.arcticmodal.js | 2 +- mail_base/views/templates.xml | 2 +- mail_check_immediately/doc/changelog.rst | 2 +- mail_move_message/data/mail_move_message_data.xml | 2 +- mail_move_message/i18n/mail_move_message.pot | 2 +- mail_private/view.xml | 2 +- mail_reply/templates.xml | 2 +- mail_sent/views/templates.xml | 2 +- mail_to/doc/changelog.rst | 2 +- mail_to/static/src/xml/recipient.xml | 2 +- mail_to/templates.xml | 2 +- mail_todo_custom/static/src/js/mail_todo_custom.js | 2 +- res_partner_mails_count/README.rst | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mail_archives/README.rst b/mail_archives/README.rst index 0395c12..dd0cac2 100644 --- a/mail_archives/README.rst +++ b/mail_archives/README.rst @@ -12,4 +12,4 @@ Further information HTML Description: https://apps.odoo.com/apps/modules/9.0/mail_archives/ -Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee \ No newline at end of file +Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee diff --git a/mail_archives/views/templates.xml b/mail_archives/views/templates.xml index a99a03d..147f1a0 100644 --- a/mail_archives/views/templates.xml +++ b/mail_archives/views/templates.xml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/mail_attachment_popup/static/lib/js/jquery.arcticmodal.js b/mail_attachment_popup/static/lib/js/jquery.arcticmodal.js index 0b66194..0db47e2 100644 --- a/mail_attachment_popup/static/lib/js/jquery.arcticmodal.js +++ b/mail_attachment_popup/static/lib/js/jquery.arcticmodal.js @@ -426,4 +426,4 @@ }; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/mail_base/views/templates.xml b/mail_base/views/templates.xml index 8846a55..cc3694d 100644 --- a/mail_base/views/templates.xml +++ b/mail_base/views/templates.xml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/mail_check_immediately/doc/changelog.rst b/mail_check_immediately/doc/changelog.rst index 013b693..4c43525 100644 --- a/mail_check_immediately/doc/changelog.rst +++ b/mail_check_immediately/doc/changelog.rst @@ -6,4 +6,4 @@ Updates `1.0.1` ------- -- FIX: incorrectly displayed last updated time when multiple threads (--workers) \ No newline at end of file +- FIX: incorrectly displayed last updated time when multiple threads (--workers) diff --git a/mail_move_message/data/mail_move_message_data.xml b/mail_move_message/data/mail_move_message_data.xml index 2b13fe2..f63eaae 100644 --- a/mail_move_message/data/mail_move_message_data.xml +++ b/mail_move_message/data/mail_move_message_data.xml @@ -6,4 +6,4 @@ crm.lead,project.task - \ No newline at end of file + diff --git a/mail_move_message/i18n/mail_move_message.pot b/mail_move_message/i18n/mail_move_message.pot index 2854cd5..4ab364b 100644 --- a/mail_move_message/i18n/mail_move_message.pot +++ b/mail_move_message/i18n/mail_move_message.pot @@ -170,4 +170,4 @@ msgstr "" #. module: mail_move_message #: help:mail_move_message.wizard,move_followers:0 msgid "Add followers of current record to a new record.\nYou must use this option, if new record has restricted access.\nYou can change default value for this option at Settings/System Parameters" -msgstr "" \ No newline at end of file +msgstr "" diff --git a/mail_private/view.xml b/mail_private/view.xml index 53232fa..dbd7cc1 100644 --- a/mail_private/view.xml +++ b/mail_private/view.xml @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/mail_reply/templates.xml b/mail_reply/templates.xml index f75bd81..1f82640 100644 --- a/mail_reply/templates.xml +++ b/mail_reply/templates.xml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/mail_sent/views/templates.xml b/mail_sent/views/templates.xml index 3e685e0..0815ad3 100644 --- a/mail_sent/views/templates.xml +++ b/mail_sent/views/templates.xml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/mail_to/doc/changelog.rst b/mail_to/doc/changelog.rst index 3aeb891..5f35720 100644 --- a/mail_to/doc/changelog.rst +++ b/mail_to/doc/changelog.rst @@ -4,4 +4,4 @@ Updates `1.0.0` ------- -- Init version \ No newline at end of file +- Init version diff --git a/mail_to/static/src/xml/recipient.xml b/mail_to/static/src/xml/recipient.xml index b7ccf19..5882eb8 100644 --- a/mail_to/static/src/xml/recipient.xml +++ b/mail_to/static/src/xml/recipient.xml @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/mail_to/templates.xml b/mail_to/templates.xml index f95bb51..24b067a 100644 --- a/mail_to/templates.xml +++ b/mail_to/templates.xml @@ -10,4 +10,4 @@ - \ No newline at end of file + diff --git a/mail_todo_custom/static/src/js/mail_todo_custom.js b/mail_todo_custom/static/src/js/mail_todo_custom.js index 983b856..66a3bfc 100644 --- a/mail_todo_custom/static/src/js/mail_todo_custom.js +++ b/mail_todo_custom/static/src/js/mail_todo_custom.js @@ -41,4 +41,4 @@ openerp.mail_todo_custom = function(session) { }, }); -}; \ No newline at end of file +}; diff --git a/res_partner_mails_count/README.rst b/res_partner_mails_count/README.rst index 25b2a27..9513807 100644 --- a/res_partner_mails_count/README.rst +++ b/res_partner_mails_count/README.rst @@ -13,4 +13,4 @@ Further information HTML Description: https://apps.odoo.com/apps/modules/9.0/res_partner_mails_count/ -Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee \ No newline at end of file +Tested on Odoo 9.0 b9f206953e3f877adf18643f154d1262842564ee From 8fb086d4e739ae44d65c60296764fb220340c377 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Wed, 25 Jan 2017 15:41:20 +0500 Subject: [PATCH 4/5] [LINT] fix semicolon --- mail_base/static/src/js/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index a9d64ef..1e1cbb3 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -485,7 +485,7 @@ var MailTools = core.Class.extend({ clear_cache_all_channels: function(){ _.each(channels, function(channel){ channel.cache = {}; - }) + }); }, add_to_cache: function (message, domain) { From 299c800e995a72a3994614a399a644e01c07065f Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Wed, 25 Jan 2017 15:50:59 +0500 Subject: [PATCH 5/5] [DOC] don't use header in changelog.rst --- mail_attachment_popup/doc/changelog.rst | 5 ----- mail_check_immediately/doc/changelog.rst | 5 ----- mail_move_message/doc/changelog.rst | 5 ----- mail_sent/doc/changelog.rst | 5 ----- 4 files changed, 20 deletions(-) diff --git a/mail_attachment_popup/doc/changelog.rst b/mail_attachment_popup/doc/changelog.rst index cc3dd23..9ee2b48 100644 --- a/mail_attachment_popup/doc/changelog.rst +++ b/mail_attachment_popup/doc/changelog.rst @@ -1,8 +1,3 @@ -.. _changelog: - -Updates -======= - `1.0.0` ------- diff --git a/mail_check_immediately/doc/changelog.rst b/mail_check_immediately/doc/changelog.rst index 013b693..b21ea9e 100644 --- a/mail_check_immediately/doc/changelog.rst +++ b/mail_check_immediately/doc/changelog.rst @@ -1,8 +1,3 @@ -.. _changelog: - -Updates -======= - `1.0.1` ------- diff --git a/mail_move_message/doc/changelog.rst b/mail_move_message/doc/changelog.rst index 2f27ae2..8ad2fe4 100644 --- a/mail_move_message/doc/changelog.rst +++ b/mail_move_message/doc/changelog.rst @@ -1,8 +1,3 @@ -.. _changelog: - -Updates -======= - `1.0.4` ------- diff --git a/mail_sent/doc/changelog.rst b/mail_sent/doc/changelog.rst index 2147d0e..9ddca10 100644 --- a/mail_sent/doc/changelog.rst +++ b/mail_sent/doc/changelog.rst @@ -1,8 +1,3 @@ -.. _changelog: - -Updates -======= - `1.0.2` -------