Browse Source

[FIX] Corrected notification content so message correctly update

pull/36/head
x620 9 years ago
parent
commit
3d2b2b5cbc
  1. 7
      mail_move_message/mail_move_message_models.py
  2. 12
      mail_move_message/static/src/js/mail_move_message.js

7
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):

12
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, []);

Loading…
Cancel
Save