From e561cd5b5d64e090371f60712b911486d7278f0c Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Wed, 30 Aug 2023 14:25:10 +0200 Subject: [PATCH] [FIX] hr_holidays_attendance: correct date overtime attendances Issue: ------ The `date` field of the `hr.attendance.overtime` model records is not the date of the related leave. Cause: ------ We use: `fields.Date.today()` instead of the leave field `date_from`. Solution: --------- Use `date_from` field of `leave`. opw-3433480 closes odoo/odoo#134156 X-original-commit: b82a338380e7e693d8123a496e36676260873828 Signed-off-by: Sofie Gvaladze (sgv) Signed-off-by: Thomas Lefebvre (thle) --- addons/hr_holidays_attendance/models/hr_leave.py | 4 ++-- addons/hr_holidays_attendance/models/hr_leave_allocation.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/hr_holidays_attendance/models/hr_leave.py b/addons/hr_holidays_attendance/models/hr_leave.py index 61a9f147d69..e841f9669dc 100644 --- a/addons/hr_holidays_attendance/models/hr_leave.py +++ b/addons/hr_holidays_attendance/models/hr_leave.py @@ -62,7 +62,7 @@ class HRLeave(models.Model): if not leave.sudo().overtime_id: leave.sudo().overtime_id = self.env['hr.attendance.overtime'].sudo().create({ 'employee_id': employee.id, - 'date': fields.Date.today(), + 'date': leave.date_from, 'adjustment': True, 'duration': -1 * duration, }) @@ -79,7 +79,7 @@ class HRLeave(models.Model): for leave in overtime_leaves: overtime = self.env['hr.attendance.overtime'].sudo().create({ 'employee_id': leave.employee_id.id, - 'date': fields.Date.today(), + 'date': leave.date_from, 'adjustment': True, 'duration': -1 * leave.number_of_hours_display }) diff --git a/addons/hr_holidays_attendance/models/hr_leave_allocation.py b/addons/hr_holidays_attendance/models/hr_leave_allocation.py index 9f88b222a05..68382b9ed27 100644 --- a/addons/hr_holidays_attendance/models/hr_leave_allocation.py +++ b/addons/hr_holidays_attendance/models/hr_leave_allocation.py @@ -42,7 +42,7 @@ class HolidaysAllocation(models.Model): if not allocation.overtime_id: allocation.sudo().overtime_id = self.env['hr.attendance.overtime'].sudo().create({ 'employee_id': allocation.employee_id.id, - 'date': fields.Date.today(), + 'date': allocation.date_from, 'adjustment': True, 'duration': -1 * duration, }) @@ -72,7 +72,7 @@ class HolidaysAllocation(models.Model): for allocation in overtime_allocations: overtime = self.env['hr.attendance.overtime'].sudo().create({ 'employee_id': allocation.employee_id.id, - 'date': fields.Date.today(), + 'date': allocation.date_from, 'adjustment': True, 'duration': -1 * allocation.number_of_hours_display })