You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FIX] hr_attendance: auto-checkout on different date
Problem: the auto-checkout feature was basing the computation on the fact that the unclosed attendance was starting today.
However, it might not always be the case, for example if the server is shutdown for more than 24 hours after checking in.
Steps to reproduce:
- Activate the auto-checkout feature
- Create an open-ended attendance for two days ago
- Run the cron
- Result: the attendance is not closed.
This commit solves the issue by taking into account the days delta between today and the check-in date.
task-5082359
closesodoo#227981
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
# Attendances where Last open attendance time + previously worked time on that day + tolerance greater than the attendances hours (including lunch) in his calendar
(sum(a.employee_id.resource_calendar_id.attendance_ids.filtered(lambdaatt: att.dayofweek==str(check_in_tz(a).weekday()) and (notatt.two_weeks_calendaroratt.week_type==str(att.get_week_type(check_in_tz(a).date())))).mapped(lambdaat: at.hour_to-at.hour_from))))
740
-
body=_('This attendance was automatically checked out because the employee exceeded the allowed time for their scheduled work hours.')
741
-
742
-
forattinto_check_out:
743
-
expected_worked_hours=sum(att.employee_id.resource_calendar_id.attendance_ids.filtered(lambdaa: a.dayofweek==str(check_in_tz(att).weekday()) and (nota.two_weeks_calendarora.week_type==str(a.get_week_type(check_in_tz(att).date())))).mapped("duration_hours"))
and (nota.two_weeks_calendarora.week_type==str(a.get_week_type(check_in_datetime.date())))
750
+
).mapped("duration_hours")
751
+
)
752
+
753
+
# Attendances where Last open attendance time + previously worked time on that day + tolerance greater than the attendances hours (including lunch) in his calendar
754
+
if (current_attendance_duration+previous_attendances_duration-max_tol) >expected_worked_hours:
0 commit comments