diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
index 8ebb03266..fc6ef0fa1 100644
--- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
+++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
@@ -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, absenteeism_card = 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(employee, 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,
@@ -266,7 +266,7 @@ class HrAttendanceDetail(models.Model):
minutes = int((hour_float - hours) * 60)
return datetime.combine(base_date, datetime.min.time()) + timedelta(hours=hours, minutes=minutes)
- def state_judgment(self, check_in, check_out, start_datetime, end_datetime, current_data):
+ def state_judgment(self, employee, check_in, check_out, start_datetime, end_datetime, current_data):
"""
判断打卡状态
:param check_in: 签到时间
@@ -284,30 +284,36 @@ class HrAttendanceDetail(models.Model):
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 employee.company_id.name == "集团本部":
+ if not self._process_shift_days(current_data):
+ return is_no_card, is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card
- # 异常和警告判断
- if is_no_card or is_early_card or is_late_card:
- is_abnormal = True
- is_warning = True
+ if not check_in or not check_out:
+ is_no_card = True
+ # 迟到判断
+ if check_in and start_datetime and check_in > start_datetime:
+ if employee.late_allowed > 0 :
+ is_late_card = False
+ employee.late_allowed -= 1
+ else:
+ 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, absenteeism_card
diff --git a/yuthon_hr_employee/data/abnormal_time_data.xml b/yuthon_hr_employee/data/abnormal_time_data.xml
index b1d65bf69..ae8152391 100644
--- a/yuthon_hr_employee/data/abnormal_time_data.xml
+++ b/yuthon_hr_employee/data/abnormal_time_data.xml
@@ -15,5 +15,19 @@
-1
+
+ 定时任务:重置物管允许迟到次数
+
+ code
+ model.compute_late_allowed()
+
+
+ 1
+ months
+
+ -1
+
+
diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py
index 5a4299953..6ab254d4c 100644
--- a/yuthon_hr_employee/models/yuthon_hr_employee.py
+++ b/yuthon_hr_employee/models/yuthon_hr_employee.py
@@ -128,7 +128,7 @@ class YuthonHrEmployee(models.Model):
previous_balance = fields.Float(string="上年结余")
quota_issued = fields.Float(string="本年发放额度")
deadline = fields.Date(string="截止日期")
-
+ late_allowed = fields.Float(string="允许迟到次数")
# 其他信息
employment_registration = fields.Text(string="就业登记办理情况")
@@ -216,6 +216,11 @@ class YuthonHrEmployee(models.Model):
security_amount = fields.Float(string="安全委员会金额", compute='_compute_subsidy_amount', store=True)
quality_inspector_amount = fields.Float(string="质检员金额", compute='_compute_subsidy_amount', store=True)
+ def compute_late_allowed(self):
+ employee = self.env["hr.employee"].search([('company_id.name', '=', '天河物管')])
+ for employee_id in employee:
+ employee_id.late_allowed = 3
+
@api.onchange('user_role_id')
def _onchange_user_role_id(self):
if self.user_role_id and self.id:
diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
index ec3150438..88ebde08e 100644
--- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
+++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
@@ -142,6 +142,7 @@
+
@@ -197,6 +198,7 @@
+