From d5f2fc2e37df1812a07b998b4a069e96f8c0d2b8 Mon Sep 17 00:00:00 2001 From: Alvaro Fuentes Date: Tue, 31 May 2022 13:20:53 +0000 Subject: [PATCH] [FIX] payment: fix misplaced sudo On 02eba891cb8cd58985837090f2b60cf263bce065 we changed https://github.com/odoo/odoo/blob/b5cf1ee3e21f2e60b8edd64f24c04c952fb7df3f/addons/payment/models/account_payment.py#L47 to https://github.com/odoo/odoo/blob/02eba891cb8cd58985837090f2b60cf263bce065/addons/payment/models/account_payment.py#L47-L48 Effectively moving the place where `sudo` is called. This causes issues during migration of some DBs upg-328570 closes odoo/odoo#92651 X-original-commit: 90c321cc8bad04f7f094a221a39ca6f647944f5d Signed-off-by: Antoine Vandevenne (anv) --- addons/payment/models/account_payment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/payment/models/account_payment.py b/addons/payment/models/account_payment.py index cb416b81c14..33823eeadc8 100644 --- a/addons/payment/models/account_payment.py +++ b/addons/payment/models/account_payment.py @@ -44,8 +44,8 @@ class AccountPayment(models.Model): def _compute_amount_available_for_refund(self): for payment in self: - tx = payment.payment_transaction_id - if tx.acquirer_id.sudo().support_refund and tx.operation != 'refund': + tx_sudo = payment.payment_transaction_id.sudo() + if tx_sudo.acquirer_id.support_refund and tx_sudo.operation != 'refund': # Only consider refund transactions that are confirmed by summing the amounts of # payments linked to such refund transactions. Indeed, should a refund transaction # be stuck forever in a transient state (due to webhook failure, for example), the