From 9ee9546d5967b1e7b534d9059cd4a79f471f250a Mon Sep 17 00:00:00 2001 From: RomainLibert Date: Mon, 22 Oct 2018 08:03:36 +0000 Subject: [PATCH] [FIX] hr_holidays: fix crash when accrual update allocations for multiple employees In case we create an allocation in byTag, byDepartment or byCompany, we need to pass the accrual flag to the children of the first allocation and only update the children allocations (namely the byEmployee allocations only). Otherwise the accrual allocation will fail Closes: #27971 opw-1895302 closes odoo/odoo#28012 --- addons/hr_holidays/models/hr_leave_allocation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index 0c2037a50ef..dae7d26d262 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -143,7 +143,7 @@ class HolidaysAllocation(models.Model): """ today = fields.Date.from_string(fields.Date.today()) - holidays = self.search([('accrual', '=', True), ('state', '=', 'validate'), + holidays = self.search([('accrual', '=', True), ('state', '=', 'validate'), ('holiday_type', '=', 'employee'), '|', ('date_to', '=', False), ('date_to', '>', fields.Datetime.now()), '|', ('nextcall', '=', False), ('nextcall', '<=', today)]) @@ -372,7 +372,8 @@ class HolidaysAllocation(models.Model): 'notes': self.notes, 'number_of_days': self.number_of_days, 'parent_id': self.id, - 'employee_id': employee.id + 'employee_id': employee.id, + 'accrual': self.accrual, } return values