[FIX] hr_holidays_attendance: Fix time off overtime duration check

Currently when a time off using an overtime is written to for any
reason, it will compare the duration of the overtime with the
number_of_hours_display. However, the duration check will always be
triggered since overtime duration is number_of_hours_display * -1

This causes problems if an overtime time off is modified for any reason
and the employee does not have enough total_overtime

closes odoo/odoo#160381

X-original-commit: 1c477259d08995d1b0bfe8ebd551452073e0c03b
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
This commit is contained in:
Dawn Hwang
2024-04-05 07:20:47 +00:00
parent a11bca1810
commit 6cb886efc0
@@ -42,7 +42,7 @@ class HRLeave(models.Model):
employee = leave.employee_id
duration = leave.number_of_hours_display
overtime_duration = leave.overtime_id.sudo().duration
if overtime_duration != duration:
if overtime_duration != -1 * duration:
if duration > employee.total_overtime - overtime_duration:
raise ValidationError(_('The employee does not have enough extra hours to extend this leave.'))
leave.overtime_id.sudo().duration = -1 * duration