[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 <smetl@users.noreply.github.com>
Signed-off-by: bfr-o <bfr-o@users.noreply.github.com>
This commit is contained in:
Benjamin Frantzen (bfr)
2020-08-24 16:59:19 +00:00
parent 0058ee62f8
commit 9591b4e4d4
+3 -2
View File
@@ -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