[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
This commit is contained in:
RomainLibert
2018-10-22 08:05:34 +00:00
parent 17bb0ca443
commit 9ee9546d59
@@ -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