[FIX] hr_holidays : no traceback when validate -> refuse -> to draft leave

Current Behaviour :
Go to Time off -> Approvals -> Time Off -> create one time off of type 'Annual Time Off 2021' for multiple employees (i.e. Anita, Abigail and Audrey) -> validate -> refuse -> set to draft -> Traceback

Behaviour after the PR :
No traceback

opw-26842777

closes odoo/odoo#79503

X-original-commit: c4103536350ed6c0da93a18992e1f9b733bd845e
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Florian Damhaut
2021-11-08 13:24:29 +00:00
parent 59c2d7fe53
commit e1566fa78f
+1 -1
View File
@@ -665,7 +665,7 @@ class HolidaysRequest(models.Model):
@api.constrains('state', 'number_of_days', 'holiday_status_id')
def _check_holidays(self):
for holiday in self:
if holiday.holiday_type != 'employee' or not holiday.employee_id or holiday.holiday_status_id.requires_allocation == 'no':
if holiday.holiday_type != 'employee' or not holiday.employee_id or not holiday.holiday_status_id or holiday.holiday_status_id.requires_allocation == 'no':
continue
mapped_days = holiday.holiday_status_id.get_employees_days([holiday.employee_id.id], holiday.date_from)
leave_days = mapped_days[holiday.employee_id.id][holiday.holiday_status_id.id]