From e40667aa7d4462517258020124dfbf988edca39a Mon Sep 17 00:00:00 2001 From: x620 Date: Wed, 18 May 2016 14:07:53 +0500 Subject: [PATCH] [FIX] add condition in base.js when model and/or res_id empty then call method send_mail_action() --- mail_base/static/src/js/base.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mail_base/static/src/js/base.js b/mail_base/static/src/js/base.js index 332fe34..8a4a7f4 100644 --- a/mail_base/static/src/js/base.js +++ b/mail_base/static/src/js/base.js @@ -786,14 +786,24 @@ chat_manager.post_message = function (data, options) { subtype_id: data.subtype_id }); - var model = new Model(options.model); - return model.call('message_post', [options.res_id], msg).then(function (msg_id) { - return MessageModel.call('message_format', [msg_id]).then(function (msgs) { - msgs[0].model = options.model; - msgs[0].res_id = options.res_id; - chat_manager.mail_tools.add_message(msgs[0]); + if (options.model && options.res_id){ + var model = new Model(options.model); + return model.call('message_post', [options.res_id], msg).then(function (msg_id) { + return MessageModel.call('message_format', [msg_id]).then(function (msgs) { + msgs[0].model = options.model; + msgs[0].res_id = options.res_id; + chat_manager.mail_tools.add_message(msgs[0]); + }); }); - }); + } else { + options.model = 'mail.compose.message'; + options.res_id = msg.id; + var compose_model = new Model(options.model); + return compose_model.call('send_mail_action', [options.res_id], { + res_model: options.model, + res_id: options.res_id + }); + } } }; chat_manager.get_message = function (id) {