refactor: streamline expense lock bypass logic in payment write method
This commit is contained in:
parent
6fe3b042b9
commit
6ec8a90f05
@ -87,11 +87,10 @@ class AccountPayment(models.Model):
|
|||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
# 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 and self._context.get('skip_expense_lock'):
|
if hr_expense_class:
|
||||||
return super(hr_expense_class, self).write(vals)
|
if self._context.get('skip_expense_lock') or any(p.expense_sheet_id and p.state == 'draft' for p in self):
|
||||||
|
return super(hr_expense_class, self.with_context(skip_expense_lock=True)).write(vals)
|
||||||
|
|
||||||
if self.expense_sheet_id and self.state == 'draft':
|
|
||||||
return super(AccountPayment, self.with_context(skip_expense_lock=True)).write(vals)
|
|
||||||
return super().write(vals)
|
return super().write(vals)
|
||||||
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user