diff --git a/hr_expense_advance_clearing/models/hr_expense_sheet.py b/hr_expense_advance_clearing/models/hr_expense_sheet.py index 4a20f33d2..a2d12abd2 100644 --- a/hr_expense_advance_clearing/models/hr_expense_sheet.py +++ b/hr_expense_advance_clearing/models/hr_expense_sheet.py @@ -71,7 +71,8 @@ def _check_constraint_clearing_amount(self): and x.advance_sheet_residual <= 0.0 and x.state in ["submit", "approve", "post"] ) - if sheets_x: # Advance Sheets with no residual left + if sheets_x and not self.env.context.get("skip_check_clearing_amount", False): + # Advance Sheets with no residual left raise ValidationError( _("Advance: %s has no amount to clear") % ", ".join(sheets_x.mapped("name")) diff --git a/hr_expense_advance_clearing/wizard/account_payment_register.py b/hr_expense_advance_clearing/wizard/account_payment_register.py index 79cdc88c1..35e8db5c3 100644 --- a/hr_expense_advance_clearing/wizard/account_payment_register.py +++ b/hr_expense_advance_clearing/wizard/account_payment_register.py @@ -96,6 +96,7 @@ def _validate_over_return(self): ) def action_create_payments(self): + self = self.with_context(skip_check_clearing_amount=True) if self._context.get("hr_return_advance", False): self._validate_over_return() self.expense_post_return_advance()