diff --git a/yuthon_wechat/models/hr_attendance_detail.py b/yuthon_wechat/models/hr_attendance_detail.py index a76fbb446..a0fa30231 100644 --- a/yuthon_wechat/models/hr_attendance_detail.py +++ b/yuthon_wechat/models/hr_attendance_detail.py @@ -266,48 +266,47 @@ class HrAttendanceDetail(models.Model): exception_type = data.get("exception_type", "") will_datetime_start = checkin_time.replace(hour=min_hour, minute=min_minute) will_datetime_end = checkin_time.replace(hour=max_hour, minute=max_minute) - if hr_employee_obj.default_planning_role_id: - if exception_type != "未打卡": - if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in: - attendance_obj.sudo().write({ - "sch_check_in_time": sch_checkin_time, - "check_in": checkin_time, - "is_late_card": checkin_time > will_datetime_start, - }) - elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out: - attendance_obj.sudo().write({ - "sch_check_out_time": sch_checkin_time, - "check_out": checkin_time, - "is_early_card": will_datetime_end > checkin_time, - }) - elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in: - attendance_obj.sudo().write({ - "sch_check_in_time": sch_checkin_time, - "check_in": checkin_time, - "is_late_card": checkin_time > will_datetime_start, - }) - elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out: - attendance_obj.sudo().write({ - "sch_check_out_time": sch_checkin_time, - "check_out": checkin_time, - "is_early_card": will_datetime_end > checkin_time, - }) - elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out: - attendance_obj.sudo().write({ - "sch_check_in_time": sch_checkin_time, - "check_in": checkin_time, - "is_late_card": checkin_time > will_datetime_start, - }) - elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out: - attendance_obj.sudo().write({ - "sch_check_out_time": sch_checkin_time, - "check_out": checkin_time, - "is_early_card": will_datetime_end > checkin_time, - }) - elif attendance_obj.is_early_card or attendance_obj.is_late_card: - attendance_obj.sudo().write({"is_abnormal": True}) - else: - attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True}) + if exception_type != "未打卡": + if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in: + attendance_obj.sudo().write({ + "sch_check_in_time": sch_checkin_time, + "check_in": checkin_time, + "is_late_card": checkin_time > will_datetime_start, + }) + elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out: + attendance_obj.sudo().write({ + "sch_check_out_time": sch_checkin_time, + "check_out": checkin_time, + "is_early_card": will_datetime_end > checkin_time, + }) + elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in: + attendance_obj.sudo().write({ + "sch_check_in_time": sch_checkin_time, + "check_in": checkin_time, + "is_late_card": checkin_time > will_datetime_start, + }) + elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out: + attendance_obj.sudo().write({ + "sch_check_out_time": sch_checkin_time, + "check_out": checkin_time, + "is_early_card": will_datetime_end > checkin_time, + }) + elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out: + attendance_obj.sudo().write({ + "sch_check_in_time": sch_checkin_time, + "check_in": checkin_time, + "is_late_card": checkin_time > will_datetime_start, + }) + elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out: + attendance_obj.sudo().write({ + "sch_check_out_time": sch_checkin_time, + "check_out": checkin_time, + "is_early_card": will_datetime_end > checkin_time, + }) + elif attendance_obj.is_early_card or attendance_obj.is_late_card: + attendance_obj.sudo().write({"is_abnormal": True}) + else: + attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True}) # else: # current_datetime_start = datetime.datetime.combine(current_data, datetime.time.min) # current_datetime_end = datetime.datetime.combine(current_data, datetime.time.max)