From 9591b4e4d4ab850ad53beee7d49e5157ce12802c Mon Sep 17 00:00:00 2001 From: "Benjamin Frantzen (bfr)" Date: Mon, 24 Aug 2020 14:26:36 +0000 Subject: [PATCH] [FIX] account_edi: fix crash when sending an invoice with an edi that has an error - When an edi.document has an error and thus does not have an attachment, trying to send the invoice by mail would cause a crash closes odoo/odoo#56450 X-original-commit: 7f9e34a5b11772af958293cd75d30cae69151497 Signed-off-by: Laurent Smet Signed-off-by: bfr-o --- addons/account_edi/models/mail_template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account_edi/models/mail_template.py b/addons/account_edi/models/mail_template.py index 3b294b1ef9c..7f0642cf66f 100644 --- a/addons/account_edi/models/mail_template.py +++ b/addons/account_edi/models/mail_template.py @@ -28,7 +28,8 @@ class MailTemplate(models.Model): continue attachment = doc.attachment_id - record_data.setdefault('attachments', []) - record_data['attachments'].append((attachment.name, attachment.datas)) + if attachment: + record_data.setdefault('attachments', []) + record_data['attachments'].append((attachment.name, attachment.datas)) return res