!3729 添加功能

Merge pull request !3729 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-07-08 08:44:26 +00:00
committed by Gitee
@@ -54,12 +54,32 @@ class AppletAttendance(Controller):
attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search([('employee_id', '=', employee_id.id), ('current_data', '=', current_date)])
check_in = attendance_id.check_in + timedelta(hours=8) if attendance_id.check_in else ''
check_out = attendance_id.check_out + timedelta(hours=8) if attendance_id.check_out else ''
check_in_start = attendance_id.shift_id.template_id.check_in_start
check_out_end = attendance_id.shift_id.template_id.check_out_end
start_minute = int((check_in_start - int(check_in_start)) * 60)
end_minute = int((check_out_end - int(check_out_end)) * 60)
start_time_str = f"{int(check_in_start):02d}-{start_minute:02d}"
end_time_str = f"{int(check_out_end):02d}-{end_minute:02d}"
if not attendance_id.shift_id:
year = attendance_id.current_data.year
month = attendance_id.current_data.month
day = attendance_id.current_data.day
current_date = datetime.today()
min_hour_from = attendance_id.employee_id.resource_id.calendar_id.attendance_ids[0].hour_from
min_hour = int(min_hour_from)
min_minute = int(min_hour_from * 10 % min_hour_from)
will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour,
minute=min_minute)
max_hour_to = attendance_id.employee_id.resource_id.calendar_id.attendance_ids[-1].hour_to
max_hour = int(max_hour_to)
max_minute = int(max_hour_to * 10 % max_hour_to)
will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour,
minute=max_minute)
start_time_str = will_datetime_start.strftime('%H:%M')
end_time_str = will_datetime_end.strftime('%H:%M')
else:
check_in_start = attendance_id.shift_id.template_id.check_in_start
check_out_end = attendance_id.shift_id.template_id.check_out_end
start_minute = int((check_in_start - int(check_in_start)) * 60)
end_minute = int((check_out_end - int(check_out_end)) * 60)
start_time_str = f"{int(check_in_start):02d}-{start_minute:02d}"
end_time_str = f"{int(check_out_end):02d}-{end_minute:02d}"
is_early_card = attendance_id.is_early_card
is_late_card = attendance_id.is_late_card
check_in_status = '缺卡' if not check_in else ('迟到' if is_late_card else '')