From ac4965e1041ceb5bae6657f9e751ad80c6ed7f46 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Mon, 13 Sep 2021 12:03:19 +0000 Subject: [PATCH] [FIX] mail: fix traceback in commands with body, commands don't linger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commands that were expecting a body were not receiving one, and sending a command would not clear the text input. This commit fixes that. task-2645395 closes odoo/odoo#76516 X-original-commit: 3274452e41c2c3c097cea3cf24da68fc67b97eb5 Related: odoo/enterprise#20865 Signed-off-by: Sébastien Theys (seb) --- .../static/src/models/channel_command/channel_command.js | 6 +++--- addons/mail/static/src/models/composer/composer.js | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/models/channel_command/channel_command.js b/addons/mail/static/src/models/channel_command/channel_command.js index 086cf9c234e..a098e3f3a14 100644 --- a/addons/mail/static/src/models/channel_command/channel_command.js +++ b/addons/mail/static/src/models/channel_command/channel_command.js @@ -96,14 +96,14 @@ function factory(dependencies) { * @static * @param {Object} param0 * @param {mail.thread} param0.channel - * @param {Object} [param0.postData={}] + * @param {Object} [param0.body=''] */ - async execute({ channel, postData = {} }) { + async execute({ channel, body = '' }) { return this.env.services.rpc({ model: 'mail.channel', method: this.methodName, args: [[channel.id]], - kwargs: postData, + kwargs: { body }, }); } diff --git a/addons/mail/static/src/models/composer/composer.js b/addons/mail/static/src/models/composer/composer.js index ad9079f4ec0..1109eba9cb3 100644 --- a/addons/mail/static/src/models/composer/composer.js +++ b/addons/mail/static/src/models/composer/composer.js @@ -206,7 +206,10 @@ function factory(dependencies) { if (this.thread.model === 'mail.channel') { const command = this._getCommandFromText(this.textInputContent); if (command) { - command.execute({ channel: this.thread, body: this.textInputContent }); + await command.execute({ channel: this.thread, body: this.textInputContent }); + if (this.exists()) { + this._reset(); + } return; } }