Merge pull request !5284 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-09-22 00:45:47 +00:00
committed by Gitee
+18 -18
View File
@@ -173,24 +173,24 @@ class HrAttendance(models.Model):
('id', '!=', attendance.id),
], order='check_in desc', limit=1)
if last_attendance_before_check_in and last_attendance_before_check_in.check_out and last_attendance_before_check_in.check_out > attendance.check_in:
raise exceptions.ValidationError(_(
"Cannot create new attendance record for %(empl_name)s, the employee was already checked in on %(datetime)s",
empl_name=attendance.employee_id.name,
datetime=format_datetime(self.env, attendance.check_in, dt_format=False)
))
if attendance.check_out:
last_attendance_before_check_out = self.env['hr.attendance'].search([
('employee_id', '=', attendance.employee_id.id),
('check_in', '<', attendance.check_out),
('id', '!=', attendance.id),
], order='check_in desc', limit=1)
if last_attendance_before_check_out and last_attendance_before_check_in != last_attendance_before_check_out:
raise exceptions.ValidationError(_(
"Cannot create new attendance record for %(empl_name)s, the employee was already checked in on %(datetime)s",
empl_name=attendance.employee_id.name,
datetime=format_datetime(self.env, last_attendance_before_check_out.check_in, dt_format=False)
))
# if last_attendance_before_check_in and last_attendance_before_check_in.check_out and last_attendance_before_check_in.check_out > attendance.check_in:
# raise exceptions.ValidationError(_(
# "Cannot create new attendance record for %(empl_name)s, the employee was already checked in on %(datetime)s",
# empl_name=attendance.employee_id.name,
# datetime=format_datetime(self.env, attendance.check_in, dt_format=False)
# ))
# if attendance.check_out:
# last_attendance_before_check_out = self.env['hr.attendance'].search([
# ('employee_id', '=', attendance.employee_id.id),
# ('check_in', '<', attendance.check_out),
# ('id', '!=', attendance.id),
# ], order='check_in desc', limit=1)
# if last_attendance_before_check_out and last_attendance_before_check_in != last_attendance_before_check_out:
# raise exceptions.ValidationError(_(
# "Cannot create new attendance record for %(empl_name)s, the employee was already checked in on %(datetime)s",
# empl_name=attendance.employee_id.name,
# datetime=format_datetime(self.env, last_attendance_before_check_out.check_in, dt_format=False)
# ))
#考勤异常提醒
def attendance_abnormal_remind(self):