From 75e9b2f383cd475f809bb99ea4e6908ef7eaff93 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Wed, 1 Mar 2023 07:24:00 +0000 Subject: [PATCH] [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 --- addons/hr_holidays/models/hr_leave_allocation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index 4710052e9ec..3ae013f1c1a 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -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)