From edc76b5f96d48090e8a413a3a9be156f67bcca28 Mon Sep 17 00:00:00 2001 From: "Benjamin Frantzen (bfr)" Date: Mon, 22 Feb 2021 09:17:05 +0000 Subject: [PATCH] [FIX] l10n_be_edi: only add the pdf to the xml if it exists Before this commit, in some cases the attachment of the Belgian EDI might not exist any longer when printing the pdf, which caused a crash when trying to embed it into the xml. closes odoo/odoo#66605 X-original-commit: ec72e3f02f4854870faccdbbb1048e5be62fa6af Signed-off-by: Laurent Smet Signed-off-by: bfr-o --- addons/l10n_be_edi/models/ir_actions_report.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/l10n_be_edi/models/ir_actions_report.py b/addons/l10n_be_edi/models/ir_actions_report.py index b8ff38642dd..0ba1ce4cbea 100644 --- a/addons/l10n_be_edi/models/ir_actions_report.py +++ b/addons/l10n_be_edi/models/ir_actions_report.py @@ -17,9 +17,8 @@ class IrActionsReport(models.Model): result = super()._postprocess_pdf_report(record, buffer) if record._name == 'account.move': - edi_document = record.edi_document_ids.filtered(lambda d: d.edi_format_id.code == 'efff_1') - if edi_document: - edi_attachment = edi_document[0].attachment_id + edi_attachment = record.edi_document_ids.filtered(lambda d: d.edi_format_id.code == 'efff_1').attachment_id + if edi_attachment: old_xml = base64.b64decode(edi_attachment.with_context(bin_size=False).datas, validate=True) tree = etree.fromstring(old_xml) document_currency_code_elements = tree.xpath("//*[local-name()='DocumentCurrencyCode']")