From e8a883ff651a2897181dfdceddea36a6cd2b11c9 Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Tue, 4 Jul 2023 12:15:38 +0000 Subject: [PATCH] [FIX] mail: prevent crash when deleting a message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since https://github.com/odoo/odoo/pull/126713, deleting a message would crash as the `mail/message/update_content` route is called without passing the `partner_ids` parameter. This commit fixes the issue by making the parameter optional. closes odoo/odoo#127284 X-original-commit: 34abd3dc1d159962a376b248134d0cd4977f3dcb Signed-off-by: Sébastien Theys (seb) --- addons/im_livechat/models/discuss_channel.py | 6 ++++-- addons/mail/controllers/thread.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/im_livechat/models/discuss_channel.py b/addons/im_livechat/models/discuss_channel.py index 62db9106c0a..b0fe38efe7a 100644 --- a/addons/im_livechat/models/discuss_channel.py +++ b/addons/im_livechat/models/discuss_channel.py @@ -109,8 +109,10 @@ class DiscussChannel(models.Model): message_body = '' % (''.join(html_links)) self._send_transient_message(self.env['res.partner'].browse(pid), message_body) - def _message_update_content(self, message, body, attachment_ids=None, strict=True, **kwargs): - super()._message_update_content(message=message, body=body, attachment_ids=attachment_ids, strict=strict, **kwargs) + def _message_update_content(self, message, body, attachment_ids=None, partner_ids=None, strict=True, **kwargs): + super()._message_update_content( + message=message, body=body, attachment_ids=attachment_ids, partner_ids=partner_ids, strict=strict, **kwargs + ) if self.channel_type == 'livechat': self.env['bus.bus']._sendone(self.uuid, 'mail.record/insert', { 'Message': { diff --git a/addons/mail/controllers/thread.py b/addons/mail/controllers/thread.py index ddbb8cb698e..601b468e3f1 100644 --- a/addons/mail/controllers/thread.py +++ b/addons/mail/controllers/thread.py @@ -83,7 +83,7 @@ class ThreadController(http.Controller): return message_data @http.route("/mail/message/update_content", methods=["POST"], type="json", auth="public") - def mail_message_update_content(self, message_id, body, attachment_ids, partner_ids): + def mail_message_update_content(self, message_id, body, attachment_ids, partner_ids=None): guest = request.env["mail.guest"]._get_guest_from_request(request) message_sudo = guest.env["mail.message"].browse(message_id).sudo().exists() if not message_sudo.is_current_user_or_guest_author and not guest.env.user._is_admin():