From e616795b083936ae529c70fdd3a5dccbda5eda30 Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Wed, 10 Jan 2024 15:09:02 +0100 Subject: [PATCH] [FIX] l10n_sa_edi: fix access to attachment of EDI document Steps to reproduce: - Install Accounting and l10n_sa_edi - Connect with a non-admin user (e.g. Marc Demo) - Switch to a SA company - Create an invoice - Click on "SEND & PRINT" => A traceback is raised when trying to access the attachment linked to the ZATCA document. Cause: Since this commit https://github.com/odoo/odoo/commit/44a4cdb3944a4b722dcfbca5e2947a4372b8501d the attachment of an EDI document is restricted to users with "Administration: Settings" rights. opw-3663305 closes odoo/odoo#149055 X-original-commit: 2fa9626f45b8c0c890d0771d731c4a13c5a7a9d1 Signed-off-by: Olivier Colson (oco) Signed-off-by: Anh Thao Pham (pta) --- addons/l10n_sa_edi/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_sa_edi/models/account_move.py b/addons/l10n_sa_edi/models/account_move.py index aba3bbdeb3c..04a202bd2c2 100644 --- a/addons/l10n_sa_edi/models/account_move.py +++ b/addons/l10n_sa_edi/models/account_move.py @@ -47,7 +47,7 @@ class AccountMove(models.Model): qr_code_str = move._l10n_sa_get_qr_code(move.journal_id, xml_content, b64decode(x509_cert), move.l10n_sa_invoice_signature, True) qr_code_str = b64encode(qr_code_str).decode() - elif zatca_document.state == 'sent' and zatca_document.attachment_id.datas: + elif zatca_document.state == 'sent' and zatca_document.sudo().attachment_id.datas: document_xml = zatca_document.attachment_id.with_context(bin_size=False).datas.decode() root = etree.fromstring(b64decode(document_xml)) qr_node = root.xpath('//*[local-name()="ID"][text()="QR"]/following-sibling::*/*')[0]