[FIX] hr_holidays: allow archiving according to the context
Steps to reproduce: Archive an employee who has allowances in the approved state. Issue: The error is triggered and that says we can't archive an allocation. Solution: Use the context to avoid triggering the error if the archiving is part of another archiving process. Introduced with the commit 1839bf83a14a12eb83a8f721f82ece7238319e43 opw-3211372 closes odoo/odoo#114385 X-original-commit: 19cbf1d68052f002bff4f1fd12f9f94d60c17df2 Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -575,7 +575,7 @@ class HolidaysAllocation(models.Model):
|
||||
return holidays
|
||||
|
||||
def write(self, values):
|
||||
if not bool(values.get('active', True)):
|
||||
if not self.env.context.get('toggle_active') and not bool(values.get('active', True)):
|
||||
if any(allocation.state not in ['draft', 'cancel', 'refuse'] for allocation in self):
|
||||
raise UserError(_('You cannot archive an allocation which is in confirm or validate state.'))
|
||||
employee_id = values.get('employee_id', False)
|
||||
|
||||
Reference in New Issue
Block a user