From 1217132bcdc1cdc73d5f095330c9bfe05ad2d18f Mon Sep 17 00:00:00 2001 From: Xavier ALT Date: Tue, 31 Jan 2023 17:26:00 +0000 Subject: [PATCH] [FIX] account_edi: fix access to edi documents attachment Following odoo/odoo@44a4cdb, account.edi.document `attachment_id` now is restricted, so force getting it's value as superuser. X-original-commit: b805e90457ef57868b9742b622465ea823b05af2 Part-of: odoo/odoo#111839 --- addons/account_edi/models/account_edi_document.py | 8 ++++++-- addons/account_edi/models/account_move.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/account_edi/models/account_edi_document.py b/addons/account_edi/models/account_edi_document.py index 40fa64a37fc..7a3a5b1b461 100644 --- a/addons/account_edi/models/account_edi_document.py +++ b/addons/account_edi/models/account_edi_document.py @@ -277,6 +277,10 @@ class AccountEdiDocument(models.Model): } """ self.ensure_one() - if not self.attachment_id: + attachment_sudo = self.sudo().attachment_id + if not attachment_sudo: return {} - return {'attachment_ids': self.attachment_id.ids} + if not (attachment_sudo.res_model and attachment_sudo.res_id): + # do not return system attachment not linked to a record + return {} + return {'attachment_ids': attachment_sudo.ids} diff --git a/addons/account_edi/models/account_move.py b/addons/account_edi/models/account_move.py index c7dcc27e5eb..2865671a44d 100644 --- a/addons/account_edi/models/account_move.py +++ b/addons/account_edi/models/account_move.py @@ -395,7 +395,7 @@ class AccountMove(models.Model): return self.edi_document_ids.filtered(lambda d: d.edi_format_id == edi_format) def _get_edi_attachment(self, edi_format): - return self._get_edi_document(edi_format).attachment_id + return self._get_edi_document(edi_format).sudo().attachment_id #################################################### # Import Electronic Document