From 76905cb423e564e96359b1ebb44a2fb9877ffb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Tue, 18 Aug 2026 18:56:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/hr_attendance_detail_wechat.py | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py index 067fe34a4..e63daac1a 100644 --- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py +++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py @@ -602,17 +602,30 @@ class HrAttendanceDetail(models.Model): if check_in and start_datetime and check_in > start_datetime: late_delta = (check_in - start_datetime).total_seconds() / 60 if is_tianhe_property: - # 天河物管:2分钟包容时间 - if employee.late_allowed == 0: - if late_delta > 2: - is_late_card = True - else: - if attendance.is_late_allowed == False: - # 迟到超过10分钟 并且也算迟扣允许迟到次数 到 - employee.late_allowed -= 1 - attendance.is_late_allowed = True - if late_delta > 10: + # 天河物管:2分钟包容时间;每月最多3次宽容迟到(不再依赖 employee.late_allowed 字段) + if late_delta > 2: + # 统计当前月份该员工已使用的宽容迟到次数(is_late_allowed=True) + month_first = current_data.replace(day=1) + if current_data.month == 12: + month_last = current_data.replace(day=31) + else: + month_last = current_data.replace(month=current_data.month + 1, day=1) - timedelta(days=1) + used_count = self.env['hr.attendance'].search_count([ + ('employee_id', '=', employee.id), + ('current_data', '>=', month_first), + ('current_data', '<=', month_last), + ('is_late_allowed', '=', True), + ('id', '!=', attendance.id), + ]) + if used_count >= 3: + # 本月已满3次宽容,不再宽容,直接算迟到(黄色也不显示) + attendance.is_late_allowed = False is_late_card = True + else: + if attendance.is_late_allowed == False: + attendance.is_late_allowed = True + if late_delta > 10: + is_late_card = True # 迟到超过60分钟标记为旷工 if late_delta > 60: