From eee6e26b37c4cb70543070efa87cd33b6497b7db Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Mon, 18 Mar 2019 15:26:04 +0000 Subject: [PATCH] [FIX] mail_enterprise: display all attachements in preview widget If res_id is not defined, this method used to crash. Made obvious by commit a26496b6e79153212973c55f20431df82c3d827b, which added a call to that function in the main controller of web. opw 1950403 closes odoo/odoo#31923 Signed-off-by: Nicolas Lempereur (nle) --- addons/mail/models/ir_attachment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/models/ir_attachment.py b/addons/mail/models/ir_attachment.py index acc14b2b6f9..4330059c495 100644 --- a/addons/mail/models/ir_attachment.py +++ b/addons/mail/models/ir_attachment.py @@ -23,5 +23,5 @@ class IrAttachment(models.Model): related_record = self.env[self.res_model].browse(self.res_id) # message_main_attachment_id field can be empty, that's why we compare to False; # we are just checking that it exists on the model before writing it - if hasattr(related_record, 'message_main_attachment_id'): + if related_record and hasattr(related_record, 'message_main_attachment_id'): related_record.message_main_attachment_id = self