From 87aaf66674173917d05c6a68975d8f856a758923 Mon Sep 17 00:00:00 2001 From: x620 Date: Fri, 29 Apr 2016 16:44:29 +0500 Subject: [PATCH] [FIX] unsubscribe and then subscribe to the event, to avoid duplication of new posts in base.js [FIX] replace "needaction_partner_ids" to "partner_ids" in models.py --- mail_base/static/src/js/base.js | 2 ++ mail_sent/models.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index 968f48d..7e7549f 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -1099,6 +1099,8 @@ function init(){ var load_menu_id = ir_model.call("xmlid_to_res_id", ["mail.mail_channel_menu_root_chat"], {}, {shadow: true}); var load_action_id = ir_model.call("xmlid_to_res_id", ["mail.mail_channel_action_client_chat"], {}, {shadow: true}); + // unsubscribe and then subscribe to the event, to avoid duplication of new messages + bus.off('notification'); bus.on('notification', null, chat_manager.mail_tools.on_notification); return $.when(load_menu_id, load_action_id, load_channels, load_emojis).then(function (menu_id, action_id) { diff --git a/mail_sent/models.py b/mail_sent/models.py index a77c2ae..99f4473 100644 --- a/mail_sent/models.py +++ b/mail_sent/models.py @@ -8,13 +8,13 @@ class MailMessage(models.Model): sent = fields.Boolean('Sent', compute="_get_sent", help='Was message sent to someone', store=True) @api.one - @api.depends('author_id', 'needaction_partner_ids') + @api.depends('author_id', 'partner_ids') def _get_sent(self): self_sudo = self.sudo() - self_sudo.sent = len(self_sudo.needaction_partner_ids) > 1 \ - or len(self_sudo.needaction_partner_ids) == 1 \ + self_sudo.sent = len(self_sudo.partner_ids) > 1 \ + or len(self_sudo.partner_ids) == 1 \ and self_sudo.author_id \ - and self_sudo.needaction_partner_ids[0].id != self_sudo.author_id.id + and self_sudo.partner_ids[0].id != self_sudo.author_id.id @api.multi def message_format(self):