[FIX] mail_enterprise: display all attachements in preview widget

If res_id is not defined, this method used to crash.
Made obvious by commit a26496b6e7,
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) <nle@odoo.com>
This commit is contained in:
Nans Lefebvre
2019-03-18 15:27:20 +00:00
parent 273fc4af6e
commit eee6e26b37
+1 -1
View File
@@ -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