From 8681eb1e665ca2a35f1d29cd28ab790624bb12de Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Fri, 11 Aug 2023 13:19:18 +0000 Subject: [PATCH] [FIX] l10n_sa_edi: fix wrong edi content returned The `_l10n_sa_get_invoice_content_edi` function is used to download the edi_content of an edi_document when this edi_document is in error. This function should return the xml encoded as a bytes, as it is then encoded in base64 in account_edi/models/account_edi_document.py otherwise a closes odoo/odoo#131837 Typeerror: "a bytes-like object is required, not 'dict'" is raised. X-original-commit: 8bf1d6e0abdd41211045d23a512be5269a7d1b0c Signed-off-by: Josse Colpaert Signed-off-by: Julien Van Roy (juvr) --- addons/l10n_sa_edi/models/account_edi_format.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/l10n_sa_edi/models/account_edi_format.py b/addons/l10n_sa_edi/models/account_edi_format.py index 4b666e016a3..4209413c56b 100644 --- a/addons/l10n_sa_edi/models/account_edi_format.py +++ b/addons/l10n_sa_edi/models/account_edi_format.py @@ -455,9 +455,7 @@ class AccountEdiFormat(models.Model): Return contents of the submitted UBL file or generate it if the invoice has not been submitted yet """ doc = invoice.edi_document_ids.filtered(lambda d: d.edi_format_id.code == 'sa_zatca' and d.state == 'sent') - if doc is not None and doc.attachment_id.datas: - return {invoice: {'xml_file': doc.attachment_id.datas.decode()}} - return {invoice: {'xml_file': self._l10n_sa_generate_zatca_template(invoice)}} + return doc.attachment_id.raw or self._l10n_sa_generate_zatca_template(invoice).encode() def _get_move_applicability(self, move): # EXTENDS account_edi