[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) <anv@odoo.com>
This commit is contained in:
Alvaro Fuentes
2022-06-01 16:26:32 +02:00
parent 964bfda3bf
commit d5f2fc2e37
+2 -2
View File
@@ -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