Browse Source

[IMP] Implements notifications for notice about change message moved status

pull/36/head
x620 9 years ago
parent
commit
5835af85db
  1. 13
      mail_move_message/controllers/main.py
  2. 2
      mail_move_message/mail_move_message_models.py
  3. 32
      mail_move_message/static/src/js/mail_move_message.js

13
mail_move_message/controllers/main.py

@ -2,6 +2,19 @@ from openerp.addons.web.controllers.main import DataSet
from openerp.tools.translate import _
from openerp import http
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:
registry, cr, uid, context = request.registry, request.cr, request.session.uid, request.context
channels.append((request.db, 'mail_move_message'))
return super(MailChatController, self)._poll(dbname, channels, last, options)
class DataSetCustom(DataSet):

2
mail_move_message/mail_move_message_models.py

@ -309,7 +309,7 @@ class mail_message(models.Model):
# Send notification
notification = {'message_ids': [self.id], 'values': vals}
self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), notification)
self.env['bus.bus'].sendone((self._cr.dbname, 'mail_move_message'), notification)
def name_get(self, cr, uid, ids, context=None):
if not (context or {}).get('extended_name'):

32
mail_move_message/static/src/js/mail_move_message.js

@ -46,28 +46,34 @@ odoo.define('mail_move_message.relocate', function (require) {
self.message_id = message_id;
self.do_action(action, {
'on_close': function(){
var message = base_obj.chat_manager.get_message(self.message_id);
chat_manager.bus.trigger('update_message', message);
self.fetch_and_render_thread();
bus.on('notification', null, self.on_notification);
}
'on_close': function(){}
});
},
on_notification: function(notification){
var model = notification[0][1];
if (model === 'ir.needaction') {
// new message in the inbox
chat_manager.mail_tools.on_needaction_notification(notification[1]);
}
}
});
base_obj.MailTools.include({
make_message: function(data){
var msg = this._super(data);
// Mark msg as moved after reload
msg.is_moved = data.is_moved || false;
return msg;
},
on_notification: function(notifications){
this._super(notifications);
_.each(notifications, function (notification) {
var model = notification[0][1];
if (model === 'mail_move_message') {
var message_id = notification[1].message_ids[0];
var message = base_obj.chat_manager.get_message(message_id);
// Mark message as moved after move and for update cache
message.is_moved = notification[1].values.is_moved;
// Update cache and accordingly message in the thread
chat_manager.mail_tools.add_to_cache(message, []);
// Call ChatAction.on_update_message(message)
chat_manager.bus.trigger('update_message', message);
}
});
}
});

Loading…
Cancel
Save