From aecfd1a3077a1f0abf8d95823cb2457f9c6d7ac1 Mon Sep 17 00:00:00 2001 From: Moens Alexandre Date: Thu, 24 Jan 2019 15:49:45 +0000 Subject: [FIX]mail:reply to message with no author When a user/partner is deleted, their messages lose their author. Replying to those may result in a failure to fetch the mails from the incomming mail server. without this commit, partner_ids == [(4, False)] and this value "goes down" all the way to the orm method "write" of the Many2many field. resulting in a SQL query like : INSERT INTO mail_message_res_partner_rel (mail_message_id, res_partner_id) (SELECT a, b FROM unnest(ARRAY[149855]) AS a, unnest(ARRAY[false]) AS b) EXCEPT (SELECT mail_message_id, res_partner_id FROM mail_message_res_partner_rel WHERE mail_message_id IN (149855)) which fails with the ProgrammingError : EXCEPT types boolean and integer cannot be matched opw-1921805 closes odoo/odoo#30528 --- addons/mail/models/mail_thread.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/mail/models/mail_thread.py') diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index aab526995f6..7cc7bfec060 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1228,7 +1228,8 @@ class MailThread(models.AbstractModel): subtype = 'mail.mt_note' if message_dict.get('parent_id'): parent_message = self.env['mail.message'].sudo().browse(message_dict['parent_id']) - partner_ids = [(4, parent_message.author_id.id)] + if parent_message.author_id: + partner_ids = [(4, parent_message.author_id.id)] else: subtype = 'mail.mt_comment' new_msg = thread.message_post(subtype=subtype, partner_ids=partner_ids, **message_dict) -- cgit v1.2.3