From 628c66df95fa56166a7033094ab90d3fe201d6f5 Mon Sep 17 00:00:00 2001 From: zhouzhou <123@qq.com> Date: Wed, 18 Dec 2024 18:41:50 +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 --- yuthon_wechat/models/hr_attendance_detail.py | 69 ++++++++++---------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/yuthon_wechat/models/hr_attendance_detail.py b/yuthon_wechat/models/hr_attendance_detail.py index e8c933358..b4866868c 100644 --- a/yuthon_wechat/models/hr_attendance_detail.py +++ b/yuthon_wechat/models/hr_attendance_detail.py @@ -322,40 +322,41 @@ class HrAttendanceDetail(models.Model): "shift_id": planning_slot_id.id, "attendance_type": "wx_work" }) - if checkin_time and checkin_type == "上班打卡" and not attendance_obj.check_in: - attendance_obj.sudo().write({ - "check_in": checkin_time, - "is_late_card": checkin_time > planning_slot_id.start_datetime, - }) - elif checkin_time and checkin_type == "下班打卡" and not attendance_obj.check_out: - attendance_obj.sudo().write({ - "check_out": checkin_time, - "is_early_card": planning_slot_id.end_datetime > checkin_time, - }) - elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and checkin_time < attendance_obj.check_in: - attendance_obj.sudo().write({ - "check_in": checkin_time, - "is_late_card": checkin_time > planning_slot_id.start_datetime, - }) - elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and checkin_time > attendance_obj.check_out: - attendance_obj.sudo().write({ - "check_out": checkin_time, - "is_early_card": planning_slot_id.end_datetime > checkin_time, - }) - elif checkin_time and not attendance_obj.check_in and not attendance_obj.check_out: - attendance_obj.sudo().write({ - "check_in": checkin_time, - "is_late_card": checkin_time > planning_slot_id.start_datetime, - }) - elif checkin_time and attendance_obj.check_in and not attendance_obj.check_out: - attendance_obj.sudo().write({ - "check_out": checkin_time, - "is_early_card": planning_slot_id.end_datetime > 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 checkin_time: + if checkin_time and checkin_type == "上班打卡" and not attendance_obj.check_in: + attendance_obj.sudo().write({ + "check_in": checkin_time, + "is_late_card": checkin_time > planning_slot_id.start_datetime, + }) + elif checkin_time and checkin_type == "下班打卡" and not attendance_obj.check_out: + attendance_obj.sudo().write({ + "check_out": checkin_time, + "is_early_card": planning_slot_id.end_datetime > checkin_time, + }) + elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and checkin_time < attendance_obj.check_in: + attendance_obj.sudo().write({ + "check_in": checkin_time, + "is_late_card": checkin_time > planning_slot_id.start_datetime, + }) + elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and checkin_time > attendance_obj.check_out: + attendance_obj.sudo().write({ + "check_out": checkin_time, + "is_early_card": planning_slot_id.end_datetime > checkin_time, + }) + elif checkin_time and not attendance_obj.check_in and not attendance_obj.check_out: + attendance_obj.sudo().write({ + "check_in": checkin_time, + "is_late_card": checkin_time > planning_slot_id.start_datetime, + }) + elif checkin_time and attendance_obj.check_in and not attendance_obj.check_out: + attendance_obj.sudo().write({ + "check_out": checkin_time, + "is_early_card": planning_slot_id.end_datetime > 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}) # elif planning_slot_id.department_id.name == '工程部': # attendance_obj = self.env['hr.attendance'].sudo().create({ # 'employee_id': hr_employee_obj.id,