@@ -198,7 +198,7 @@ class HrAttendanceDetail(models.Model):
|
||||
)
|
||||
# 获取正常上下班时间
|
||||
sch_check_in_time, sch_check_out_time = self.normal_clock_in_time(template, current_data)
|
||||
is_no_card, is_early_card, is_late_card, is_abnormal, is_warning = self.state_judgment(check_in_time, check_out_time, sch_check_in_time, sch_check_out_time, current_data)
|
||||
is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card = self.state_judgment(check_in_time, check_out_time, sch_check_in_time, sch_check_out_time, current_data)
|
||||
if attendance:
|
||||
attendance.write({
|
||||
'check_in': check_in_time,
|
||||
@@ -208,6 +208,7 @@ class HrAttendanceDetail(models.Model):
|
||||
'is_late_card': is_late_card,
|
||||
'is_abnormal': is_abnormal,
|
||||
'is_warning': is_warning,
|
||||
'absenteeism_card': absenteeism_card,
|
||||
})
|
||||
else:
|
||||
self.env['hr.attendance'].create({
|
||||
@@ -222,6 +223,7 @@ class HrAttendanceDetail(models.Model):
|
||||
'is_late_card': is_late_card,
|
||||
'is_abnormal': is_abnormal,
|
||||
'is_warning': is_warning,
|
||||
'absenteeism_card': absenteeism_card,
|
||||
})
|
||||
|
||||
def normal_clock_in_time(self, template, current_data):
|
||||
@@ -272,25 +274,42 @@ class HrAttendanceDetail(models.Model):
|
||||
:param start_datetime: 标准上班打卡时间
|
||||
:param end_datetime: 标准下班打卡时间
|
||||
:param current_data: 打卡日期
|
||||
:return:
|
||||
:return: is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
"""
|
||||
is_no_card = False
|
||||
is_early_card = False
|
||||
is_late_card = False
|
||||
is_abnormal = False
|
||||
is_warning = False
|
||||
absenteeism_card = False
|
||||
|
||||
# 判断是否工作日
|
||||
if self._process_shift_days(current_data):
|
||||
if not check_in or not check_out:
|
||||
is_no_card = True
|
||||
# 迟到判断
|
||||
if check_in and start_datetime and check_in > start_datetime:
|
||||
is_late_card = True
|
||||
# 计算迟到时长(分钟)
|
||||
late_delta = (check_in - start_datetime).total_seconds() / 60
|
||||
# 迟到超过60分钟标记为旷工
|
||||
if late_delta > 60:
|
||||
absenteeism_card = True
|
||||
# 早退判断
|
||||
if check_out and end_datetime and check_out < end_datetime:
|
||||
is_early_card = True
|
||||
# 计算早退时长(分钟)
|
||||
early_delta = (end_datetime - check_out).total_seconds() / 60
|
||||
# 早退超过60分钟标记为旷工
|
||||
if early_delta > 60:
|
||||
absenteeism_card = True
|
||||
|
||||
# 异常和警告判断
|
||||
if is_no_card or is_early_card or is_late_card:
|
||||
is_abnormal = True
|
||||
is_warning = True
|
||||
return is_no_card, is_early_card, is_late_card, is_abnormal, is_warning
|
||||
|
||||
return is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
|
||||
|
||||
def _process_shift_days(self, current_data):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user