From 6cb886efc0b2e5f9d3b4dbd6f285d973c17b5108 Mon Sep 17 00:00:00 2001 From: Dawn Hwang Date: Sun, 31 Mar 2024 21:51:26 +0200 Subject: [PATCH] [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) --- addons/hr_holidays_attendance/models/hr_leave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_holidays_attendance/models/hr_leave.py b/addons/hr_holidays_attendance/models/hr_leave.py index b54396ee703..d06105a7206 100644 --- a/addons/hr_holidays_attendance/models/hr_leave.py +++ b/addons/hr_holidays_attendance/models/hr_leave.py @@ -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