From 3d2b2b5cbc71480226ac9999fd5baff47d92791e Mon Sep 17 00:00:00 2001 From: x620 Date: Wed, 15 Jun 2016 15:56:06 +0500 Subject: [PATCH] [FIX] Corrected notification content so message correctly update --- mail_move_message/mail_move_message_models.py | 7 ++++++- mail_move_message/static/src/js/mail_move_message.js | 12 +++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mail_move_message/mail_move_message_models.py b/mail_move_message/mail_move_message_models.py index c05deff..c3783b1 100644 --- a/mail_move_message/mail_move_message_models.py +++ b/mail_move_message/mail_move_message_models.py @@ -314,7 +314,12 @@ class mail_message(models.Model): }) # Send notification - notification = {'message_ids': [self.id], 'values': vals} + notification = { + 'id': self.id, + 'res_id': vals.get('res_id'), + 'model': vals.get('model'), + 'is_moved': vals['is_moved'] + } self.env['bus.bus'].sendone((self._cr.dbname, 'mail_move_message'), notification) def name_get(self, cr, uid, ids, context=None): diff --git a/mail_move_message/static/src/js/mail_move_message.js b/mail_move_message/static/src/js/mail_move_message.js index babc36c..85869e8 100644 --- a/mail_move_message/static/src/js/mail_move_message.js +++ b/mail_move_message/static/src/js/mail_move_message.js @@ -72,14 +72,16 @@ odoo.define('mail_move_message.relocate', function (require) { var self = this; _.each(notifications, function (notification) { var model = notification[0][1]; - var message_id = notification[1].message_ids[0]; + var message_id = notification[1].id; var message = base_obj.chat_manager.get_message(message_id); - if (model === 'mail_move_message') { - // Mark message as moved after move and for update cache - message.is_moved = notification[1].values.is_moved; + if (model === 'mail_move_message' && message) { + message.res_id = notification[1].res_id; + message.model = notification[1].model; + // Mark message as moved after move + message.is_moved = notification[1].is_moved; // Update cache and accordingly message in the thread self.add_to_cache(message, []); - // Call ChatAction.on_update_message(message) + // Call thread.on_update_message(message) chat_manager.bus.trigger('update_message', message); } else if (model === 'mail_move_message.delete_message') { self.remove_from_cache(message, []);