From 6fc645230d4132abceb1a82dca5ec55a80b257c8 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Tue, 5 May 2026 14:53:55 +0700 Subject: [PATCH] refactor: use self.env.context instead of self._context to safely retrieve skip_expense_lock flag --- models/account_payment.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/account_payment.py b/models/account_payment.py index e227119..6e1ed26 100644 --- a/models/account_payment.py +++ b/models/account_payment.py @@ -42,7 +42,7 @@ class AccountPayment(models.Model): # Triple Jumper: If we have the bypass flag, we jump over the hr_expense method. # This works in tandem with our Model-level jumpers in account_move and account_move_line. hr_expense_class = self._get_hr_expense_base_class() - if self._context.get('skip_expense_lock') and hr_expense_class: + if self.env.context.get('skip_expense_lock') and hr_expense_class: super(hr_expense_class, self)._synchronize_to_moves(changed_fields) else: super()._synchronize_to_moves(changed_fields) @@ -56,7 +56,7 @@ class AccountPayment(models.Model): def _synchronize_from_moves(self, changed_fields): # 1. Standard sync with jumper support hr_expense_class = self._get_hr_expense_base_class() - if self._context.get('skip_expense_lock') and hr_expense_class: + if self.env.context.get('skip_expense_lock') and hr_expense_class: super(hr_expense_class, self)._synchronize_from_moves(changed_fields) else: super()._synchronize_from_moves(changed_fields) @@ -88,7 +88,7 @@ class AccountPayment(models.Model): # Propagate bypass flag during writes to avoid locked checks hr_expense_class = self._get_hr_expense_base_class() if hr_expense_class: - if self._context.get('skip_expense_lock') or any(p.expense_ids and p.state == 'draft' for p in self): + if self.env.context.get('skip_expense_lock') or any(p.expense_ids and p.state == 'draft' for p in self): return super(hr_expense_class, self.with_context(skip_expense_lock=True)).write(vals) return super().write(vals)