From b5e6debe77da653ae8d1e17d803dcb0125bf64ac Mon Sep 17 00:00:00 2001 From: x620 Date: Wed, 15 Jun 2016 11:43:27 +0500 Subject: [PATCH] [REF] Replaced on_move_message() methods to thread class to removal duplication code --- .../static/src/js/mail_move_message.js | 43 ++++++------------- 1 file changed, 13 insertions(+), 30 deletions(-) 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 3dd0457..babc36c 100644 --- a/mail_move_message/static/src/js/mail_move_message.js +++ b/mail_move_message/static/src/js/mail_move_message.js @@ -5,6 +5,7 @@ odoo.define('mail_move_message.relocate', function (require) { var chat_manager = require('mail.chat_manager'); var base_obj = require('mail_base.base'); var thread = require('mail.ChatThread'); + var chatter = require('mail.Chatter'); var Model = require('web.Model'); var form_common = require('web.form_common'); var widgets = require('web.form_widgets'); @@ -12,23 +13,14 @@ odoo.define('mail_move_message.relocate', function (require) { var _t = core._t; - // Add click reaction in the events of the thread object thread.include({ init: function(){ this._super.apply(this, arguments); + // Add click reaction in the events of the thread object this.events['click .oe_move'] = function(event) { var message_id = $(event.currentTarget).data('message-id'); this.trigger("move_message", message_id); } - } - }); - - var chatter = require('mail.Chatter'); - chatter.include({ - start: function() { - var result = this._super.apply(this, arguments); - this.thread.on('move_message', this, this.on_move_message); - return $.when(result).done(function() {}); }, on_move_message: function(message_id){ var action = { @@ -48,32 +40,23 @@ odoo.define('mail_move_message.relocate', function (require) { } }); + chatter.include({ + start: function() { + var result = this._super.apply(this, arguments); + // For show wizard in the form + this.thread.on('move_message', this, this.thread.on_move_message); + return $.when(result).done(function() {}); + } + }); + var ChatAction = core.action_registry.get('mail.chat.instant_messaging'); ChatAction.include({ start: function() { var result = this._super.apply(this, arguments); - this.thread.on('move_message', this, this.on_move_message); + // For show wizard in the channels + this.thread.on('move_message', this, this.thread.on_move_message); return $.when(result).done(function() {}); - }, - on_move_message: function(message_id){ - var self = this; - var context = {'default_message_id': message_id}; - var action = { - name: _t('Relocate Message'), - type: 'ir.actions.act_window', - res_model: 'mail_move_message.wizard', - view_mode: 'form', - view_type: 'form', - views: [[false, 'form']], - target: 'new', - context: context - }; - self.message_id = message_id; - - self.do_action(action, { - 'on_close': function(){} - }); } });