Skip to content
Snippets Groups Projects
Commit edc76b5f authored by Benjamin Frantzen (bfr)'s avatar Benjamin Frantzen (bfr)
Browse files

[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: ec72e3f0
Signed-off-by: default avatarLaurent Smet <smetl@users.noreply.github.com>
Signed-off-by: default avatarbfr-o <bfr-o@users.noreply.github.com>
parent c14622fc
No related branches found
No related tags found
No related merge requests found
......@@ -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']")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment