[FIX] account_edi_ubl_cii: fix embedding of pdf in xml

The embedding of the pdf inside the xml should only take place
for a defined list of EDI formats (bis 3, ubl_de, nlcius),
not for all. Otherwise, we get unexpected behaviours when
generating other EDI's xml (e.g. l10n_pe_edi).

closes odoo/odoo#95795

X-original-commit: 75a87bc7fa1f3331efe2048bb949e3426df2dc57
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
This commit is contained in:
Julien Van Roy
2022-07-12 12:00:50 +02:00
parent e0c179b6d2
commit 4cdd9a0d86
@@ -13,7 +13,10 @@ class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
def _add_pdf_into_invoice_xml(self, invoice, stream_data):
for edi_attachment in invoice.edi_document_ids.attachment_id:
# exclude efff because it's handled by l10n_be_edi
format_codes = ['ubl_bis3', 'ubl_de', 'nlcius_1']
edi_attachments = invoice.edi_document_ids.filtered(lambda d: d.edi_format_id.code in format_codes).attachment_id
for edi_attachment in edi_attachments:
old_xml = base64.b64decode(edi_attachment.with_context(bin_size=False).datas, validate=True)
tree = etree.fromstring(old_xml)
anchor_elements = tree.xpath("//*[local-name()='AccountingSupplierParty']")