From d052fc27af48c6bb0f96e46e3c86dbeba76e68a4 Mon Sep 17 00:00:00 2001 From: Florent de Labarre Date: Tue, 25 Jul 2023 08:51:47 +0200 Subject: [PATCH] [FIX] account: don't allow unlinking payment method lines used on non-accessible payments In case of the user have no access to all account.payment, the record can be deleted. closes odoo/odoo#135415 X-original-commit: 5086b39e44230a14a6c1c65bde4851f062f10e38 Signed-off-by: Olivier Colson (oco) --- addons/account/models/account_payment_method.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_payment_method.py b/addons/account/models/account_payment_method.py index ed5cb399208..915799766d2 100644 --- a/addons/account/models/account_payment_method.py +++ b/addons/account/models/account_payment_method.py @@ -161,7 +161,7 @@ class AccountPaymentMethodLine(models.Model): """ unused_payment_method_lines = self for line in self: - payment_count = self.env['account.payment'].search_count([('payment_method_line_id', '=', line.id)]) + payment_count = self.env['account.payment'].sudo().search_count([('payment_method_line_id', '=', line.id)]) if payment_count > 0: unused_payment_method_lines -= line