refactor: use self.env.context instead of self._context to safely retrieve skip_expense_lock flag
This commit is contained in:
parent
3d96ca446b
commit
6fc645230d
@ -42,7 +42,7 @@ class AccountPayment(models.Model):
|
|||||||
# Triple Jumper: If we have the bypass flag, we jump over the hr_expense method.
|
# 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.
|
# 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()
|
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)
|
super(hr_expense_class, self)._synchronize_to_moves(changed_fields)
|
||||||
else:
|
else:
|
||||||
super()._synchronize_to_moves(changed_fields)
|
super()._synchronize_to_moves(changed_fields)
|
||||||
@ -56,7 +56,7 @@ class AccountPayment(models.Model):
|
|||||||
def _synchronize_from_moves(self, changed_fields):
|
def _synchronize_from_moves(self, changed_fields):
|
||||||
# 1. Standard sync with jumper support
|
# 1. Standard sync with jumper support
|
||||||
hr_expense_class = self._get_hr_expense_base_class()
|
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)
|
super(hr_expense_class, self)._synchronize_from_moves(changed_fields)
|
||||||
else:
|
else:
|
||||||
super()._synchronize_from_moves(changed_fields)
|
super()._synchronize_from_moves(changed_fields)
|
||||||
@ -88,7 +88,7 @@ class AccountPayment(models.Model):
|
|||||||
# Propagate bypass flag during writes to avoid locked checks
|
# Propagate bypass flag during writes to avoid locked checks
|
||||||
hr_expense_class = self._get_hr_expense_base_class()
|
hr_expense_class = self._get_hr_expense_base_class()
|
||||||
if hr_expense_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(hr_expense_class, self.with_context(skip_expense_lock=True)).write(vals)
|
||||||
|
|
||||||
return super().write(vals)
|
return super().write(vals)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user