[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
This commit is contained in:
Xavier ALT
2023-02-03 16:32:12 +01:00
parent 0bb95cb8d6
commit 1217132bcd
2 changed files with 7 additions and 3 deletions
@@ -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}
+1 -1
View File
@@ -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