@@ -113,19 +113,13 @@ class HrAttendanceDetail(models.Model):
|
||||
"""同步打卡记录到hr.attendance 更新上下班打卡时间 """
|
||||
checkin_date = fields.Date.from_string(record.checkin_time)
|
||||
attendance = self.env['hr.attendance'].search([
|
||||
('employee_id', '=', record.employee_id.id),
|
||||
('employee_id.name', '=', '叶华锋'),
|
||||
('current_data', '=', checkin_date)
|
||||
], limit=1)
|
||||
if attendance:
|
||||
if not attendance.check_in:
|
||||
attendance.check_in = record.checkin_time
|
||||
elif not attendance.check_out:
|
||||
attendance.check_out = record.checkin_time
|
||||
existing_checkout = fields.Datetime.from_string(attendance.check_out)
|
||||
new_checkout = fields.Datetime.from_string(record.checkin_time)
|
||||
# 只在新打卡时间更晚的情况下更新
|
||||
if new_checkout > existing_checkout:
|
||||
attendance.check_out = record.checkin_time
|
||||
attendance.check_out = record.checkin_time - timedelta(hours=8)
|
||||
|
||||
|
||||
# 传参按一个人打卡一次传参
|
||||
|
||||
Reference in New Issue
Block a user