From adf534f2bfa5fd93e6bccdfa6657b522a7225e01 Mon Sep 17 00:00:00 2001 From: Alvaro Fuentes Date: Fri, 3 Jun 2022 08:23:47 +0000 Subject: [PATCH] [FIX] payment: compute `related_partner_ids` with sudo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `related_partner_ids` is used in the form view of account.payment https://github.com/odoo/odoo/blob/43fccd7aaa83117c95babc52d60dd1c26b28335a/addons/payment/views/account_payment_views.xml#L14 It is only needed for electronic payments to display the payment token ids (as part of its domain) https://github.com/odoo/odoo/blob/45f5167b956521f0a183ff1b1cc75fa1b273866c/addons/payment/models/account_payment.py#L13-L21 and for draft payments only. https://github.com/odoo/odoo/blob/43fccd7aaa83117c95babc52d60dd1c26b28335a/addons/payment/views/account_payment_views.xml#L16 Before this change the form view will fail when partner_id has a company that is not in the context. This is not incorrect, but it is unexpected as `related_partner_ids` is not needed to just show the form view. A way to reproduce the issue is to confirm a payment, then change the partner company to a company not accessible for current user. This causes issues during migrations: the form view for the failing payments is displayed just fine for versions <=13.0 closes odoo/odoo#98623 X-original-commit: a126f007573a41d22108d9d7887f92b6926ef3ec Signed-off-by: William André (wan) Signed-off-by: Alvaro Fuentes Suarez (afu) --- addons/payment/models/account_payment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/payment/models/account_payment.py b/addons/payment/models/account_payment.py index ace7a86ca28..869305c7160 100644 --- a/addons/payment/models/account_payment.py +++ b/addons/payment/models/account_payment.py @@ -24,7 +24,8 @@ class AccountPayment(models.Model): # == Display purpose fields == suitable_payment_token_ids = fields.Many2many( comodel_name='payment.token', - compute='_compute_suitable_payment_token_ids' + compute='_compute_suitable_payment_token_ids', + compute_sudo=True, ) # Technical field used to hide or show the payment_token_id if needed use_electronic_payment_method = fields.Boolean(