[FIX] hr_holidays: fix time off with allocation of one day

As an HR officer, when you create an allocation of one day for a user,
you need to be able to put a time off on that person, following the allocation.
But for the moment, we got an error saying there is no valid allocation on that day.

If you create an allocation of 1 day, you need to be able to put a time off on
that specific day without any error message.

task-2696771

closes odoo/odoo#80196

X-original-commit: 60f691bbac660d47404b35242303288880f084f7
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Philippe Wauthy
2021-11-22 17:26:53 +00:00
parent 5945e8e4e3
commit 5cdb8f51a3
+3 -3
View File
@@ -364,9 +364,9 @@ class HolidaysRequest(models.Model):
date_to = leave.date_to.replace(tzinfo=UTC).astimezone(timezone(leave.tz)).date()
date_from = leave.date_from.replace(tzinfo=UTC).astimezone(timezone(leave.tz)).date()
for allocation in allocations_dict[(leave.holiday_status_id.id, leave.employee_id.id)]:
date_to_check = allocation['date_to'] > date_to if allocation['date_to'] else False
date_from_check = allocation['date_to'] is False and allocation['date_from'] <= date_from
if (date_to_check or date_from_check):
date_to_check = allocation['date_to'] >= date_to if allocation['date_to'] else True
date_from_check = allocation['date_from'] <= date_from
if (date_to_check and date_from_check):
found_allocation = allocation['id']
break
leave.holiday_allocation_id = self.env['hr.leave.allocation'].browse(found_allocation) if found_allocation else False