From 87147c935f44cb2b6f40d5d0bd4f5304f275e69a Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Mon, 31 Oct 2022 10:24:21 +0000 Subject: [PATCH] [FIX] mail_bot: fix mail bot onboarding tour display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this PR, the mail bot would have answered to every incoming messages including system notifications. Answering to system notifications makes no sense and leads to the answer being formatted as a notification since the mail bot copies the message type of the message being answered. This PR fixes the issue by preventing the mail bot from answering anything else than comments. task-3044856 closes odoo/odoo#104636 X-original-commit: bb76e083d5adcc955967680c46b9cf2e39402783 Signed-off-by: Sébastien Theys (seb) --- addons/mail_bot/models/mail_bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail_bot/models/mail_bot.py b/addons/mail_bot/models/mail_bot.py index d436df67384..50ad2db6154 100644 --- a/addons/mail_bot/models/mail_bot.py +++ b/addons/mail_bot/models/mail_bot.py @@ -22,14 +22,14 @@ class MailBot(models.AbstractModel): :param command: the name of the called command if the logic is not triggered by a message_post """ odoobot_id = self.env['ir.model.data']._xmlid_to_res_id("base.partner_root") - if len(record) != 1 or values.get("author_id") == odoobot_id: + if len(record) != 1 or values.get("author_id") == odoobot_id or values.get("message_type") != "comment" and not command: return if self._is_bot_pinged(values) or self._is_bot_in_private_channel(record): body = values.get("body", "").replace(u'\xa0', u' ').strip().lower().strip(".!") answer = self._get_answer(record, body, values, command) if answer: - message_type = values.get('message_type', 'comment') - subtype_id = values.get('subtype_id', self.env['ir.model.data']._xmlid_to_res_id('mail.mt_comment')) + message_type = 'comment' + subtype_id = self.env['ir.model.data']._xmlid_to_res_id('mail.mt_comment') record.with_context(mail_create_nosubscribe=True).sudo().message_post(body=answer, author_id=odoobot_id, message_type=message_type, subtype_id=subtype_id) def _get_answer(self, record, body, values, command=False):