[FIX] hr_(holidays_)attendance: recompute overtime on leaves > 1 day
1/ When approving / refusing a leave spanning multiple days, the overtimes were only recomputed for the starting date and not the whole period. 2/ Overtimes should be computed whatever the kind of time off that's been taken (Absence or Other). task-3073155 closes odoo/odoo#106751 X-original-commit: 116d7cb46132404354e00e67a2364b8239fcdce5 Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -163,7 +163,7 @@ class HrAttendance(models.Model):
|
||||
start, stop, emp.resource_id
|
||||
)[emp.resource_id.id]
|
||||
# Substract Global Leaves and Employee's Leaves
|
||||
leave_intervals = emp.resource_calendar_id._leave_intervals_batch(start, stop, emp.resource_id)
|
||||
leave_intervals = emp.resource_calendar_id._leave_intervals_batch(start, stop, emp.resource_id, domain=[])
|
||||
expected_attendances -= leave_intervals[False] | leave_intervals[emp.resource_id.id]
|
||||
|
||||
# working_times = {date: [(start, stop)]}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from collections import defaultdict
|
||||
from datetime import timedelta
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
@@ -95,6 +96,7 @@ class HRLeave(models.Model):
|
||||
employee_dates = defaultdict(set)
|
||||
for leave in self:
|
||||
if leave.employee_id and leave.employee_company_id.hr_attendance_overtime:
|
||||
employee_dates[leave.employee_id].add(self.env['hr.attendance']._get_day_start_and_day(leave.employee_id, leave.date_from))
|
||||
for d in range((leave.date_to - leave.date_from).days + 1):
|
||||
employee_dates[leave.employee_id].add(self.env['hr.attendance']._get_day_start_and_day(leave.employee_id, leave.date_from + timedelta(days=d)))
|
||||
if employee_dates:
|
||||
self.env['hr.attendance']._update_overtime(employee_dates)
|
||||
|
||||
Reference in New Issue
Block a user