summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Frantzen (bfr) <bfr@odoo.com>2021-02-22 09:17:05 +0000
committerBenjamin Frantzen (bfr) <bfr@odoo.com>2021-02-22 09:56:33 +0000
commitec72e3f02f4854870faccdbbb1048e5be62fa6af (patch)
treec09da493ccda5569a956643764f4219333fb8f0b
parent99f891f0d1614b7a783fd55c0a9fdcb1ae6251da (diff)
[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#66588 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
-rw-r--r--addons/l10n_be_edi/models/ir_actions_report.py5
1 files 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']")