Browse Source

[ADD] Added "mail_move_message.delete_message"

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

1
mail_move_message/controllers/main.py

@ -13,6 +13,7 @@ class MailChatController(openerp.addons.bus.controllers.main.BusController):
if request.session.uid: if request.session.uid:
registry, cr, uid, context = request.registry, request.cr, request.session.uid, request.context registry, cr, uid, context = request.registry, request.cr, request.session.uid, request.context
channels.append((request.db, 'mail_move_message')) channels.append((request.db, 'mail_move_message'))
channels.append((request.db, 'mail_move_message.delete_message'))
return super(MailChatController, self)._poll(dbname, channels, last, options) return super(MailChatController, self)._poll(dbname, channels, last, options)

6
mail_move_message/mail_move_message_models.py

@ -195,7 +195,13 @@ class wizard(models.TransientModel):
@api.one @api.one
def delete(self): def delete(self):
msg_id = self.message_id.id
self.message_id.unlink() self.message_id.unlink()
# Send notification
notification = {'message_ids': [msg_id]}
self.env['bus.bus'].sendone((self._cr.dbname, 'mail_move_message.delete_message'), notification)
return {} return {}
@api.model @api.model

13
mail_move_message/static/src/js/mail_move_message.js

@ -62,8 +62,8 @@ odoo.define('mail_move_message.relocate', function (require) {
this._super(notifications); this._super(notifications);
_.each(notifications, function (notification) { _.each(notifications, function (notification) {
var model = notification[0][1]; var model = notification[0][1];
if (model === 'mail_move_message') {
var message_id = notification[1].message_ids[0]; var message_id = notification[1].message_ids[0];
if (model === 'mail_move_message') {
var message = base_obj.chat_manager.get_message(message_id); var message = base_obj.chat_manager.get_message(message_id);
// Mark message as moved after move and for update cache // Mark message as moved after move and for update cache
@ -72,6 +72,17 @@ odoo.define('mail_move_message.relocate', function (require) {
chat_manager.mail_tools.add_to_cache(message, []); chat_manager.mail_tools.add_to_cache(message, []);
// Call ChatAction.on_update_message(message) // Call ChatAction.on_update_message(message)
chat_manager.bus.trigger('update_message', message); chat_manager.bus.trigger('update_message', message);
} else if (model === 'mail_move_message.delete_message') {
chat_manager.get_messages(
// TODO: получить channel.id и this.domain
{channel_id: this.channel.id, domain: this.domain}
).then(function (messages) {
var options = self.get_thread_rendering_options(messages);
thread.remove_message_and_render(message_id, messages, options)
.then(function () {
self.update_button_status(messages.length === 0);
});
});
} }
}); });
} }

Loading…
Cancel
Save