添加功能
This commit is contained in:
@@ -314,36 +314,39 @@ class HrAttendance(models.Model):
|
||||
# 判断是否为工作日
|
||||
is_workday = self._process_shift_days(today)
|
||||
for employee in all_employees:
|
||||
# 查找该员工当天的考勤记录
|
||||
employee_record = attend_records.filtered(
|
||||
lambda r: r.employee_id.id == employee.id
|
||||
)
|
||||
# 白名单不做处理
|
||||
resource_user_ids = employee.resource_calendar_id.resource_user_ids.ids
|
||||
if employee.id not in resource_user_ids:
|
||||
# 查找该员工当天的考勤记录
|
||||
employee_record = attend_records.filtered(
|
||||
lambda r: r.employee_id.id == employee.id
|
||||
)
|
||||
|
||||
# 工作日打卡情况判断
|
||||
if is_workday:
|
||||
if employee_record:
|
||||
is_no_card = (not employee_record.check_in or not employee_record.check_out) and (not employee_record.is_clock_card or not employee_record.is_workflow)
|
||||
# 工作日打卡情况判断
|
||||
if is_workday:
|
||||
if employee_record:
|
||||
is_no_card = (not employee_record.check_in or not employee_record.check_out) and (not employee_record.is_clock_card or not employee_record.is_workflow)
|
||||
else:
|
||||
is_no_card = True
|
||||
else:
|
||||
is_no_card = True
|
||||
else:
|
||||
is_no_card = False
|
||||
is_no_card = False
|
||||
|
||||
if employee_record:
|
||||
# 更新现有记录的缺卡状态
|
||||
employee_record.write({'is_no_card': is_no_card})
|
||||
if is_no_card == True:
|
||||
employee_record.write({'absenteeism_card': True,
|
||||
'is_abnormal': True
|
||||
})
|
||||
else:
|
||||
# 没有记录且需要标记为缺卡时,创建新记录
|
||||
self.env['hr.attendance'].create({
|
||||
'employee_id': employee.id,
|
||||
'current_data': today,
|
||||
'is_no_card': is_no_card,
|
||||
'check_in': False,
|
||||
'check_out': False
|
||||
})
|
||||
if employee_record:
|
||||
# 更新现有记录的缺卡状态
|
||||
employee_record.write({'is_no_card': is_no_card})
|
||||
if is_no_card == True:
|
||||
employee_record.write({'absenteeism_card': True,
|
||||
'is_abnormal': True
|
||||
})
|
||||
else:
|
||||
# 没有记录且需要标记为缺卡时,创建新记录
|
||||
self.env['hr.attendance'].create({
|
||||
'employee_id': employee.id,
|
||||
'current_data': today,
|
||||
'is_no_card': is_no_card,
|
||||
'check_in': False,
|
||||
'check_out': False
|
||||
})
|
||||
|
||||
def _process_shift_days(self, current_data):
|
||||
"""
|
||||
@@ -429,6 +432,22 @@ class HrAttendance(models.Model):
|
||||
title="打卡异常提醒", description="本月迟到: {}\n本月缺卡: {}\n本月早退: {}\n".format(is_late_card, is_no_card, is_early_card),
|
||||
url=url, btntxt="详细信息")
|
||||
|
||||
def update_state(self):
|
||||
attendance_ids = self.env["hr.attendance"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id'))
|
||||
)
|
||||
for rec in attendance_ids:
|
||||
rec.write({'is_no_card': False,
|
||||
'is_early_card': False,
|
||||
'shift_name': False,
|
||||
'is_holiday': False,
|
||||
'is_week': False,
|
||||
'is_late_card': False,
|
||||
'is_abnormal': False,
|
||||
'is_warning': False,
|
||||
'absenteeism_card': False
|
||||
})
|
||||
|
||||
def button_controls_wizard(self):
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
@@ -1167,6 +1186,14 @@ class HrAttendance(models.Model):
|
||||
if record.employee_id.resource_id in related_resources_set:
|
||||
record.shift_name = '休息'
|
||||
record.is_week = True
|
||||
record.write({
|
||||
'is_early_card': False,
|
||||
'is_late_card': False,
|
||||
'is_abnormal': False,
|
||||
'is_warning': False,
|
||||
'is_no_card': False,
|
||||
'absenteeism_card': False,
|
||||
})
|
||||
continue
|
||||
|
||||
if record.current_data:
|
||||
@@ -1208,6 +1235,18 @@ class HrAttendance(models.Model):
|
||||
|
||||
record.is_holiday = is_holiday
|
||||
|
||||
if record.employee_id.id in record.employee_id.resource_calendar_id.resource_user_ids.ids:
|
||||
record.write({'is_no_card': False,
|
||||
'is_early_card': False,
|
||||
'shift_name':False,
|
||||
'is_holiday':False,
|
||||
'is_week':False,
|
||||
'is_late_card': False,
|
||||
'is_abnormal': False,
|
||||
'is_warning': False,
|
||||
'absenteeism_card': False
|
||||
})
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
record = super(HrAttendance, self).create(vals)
|
||||
|
||||
@@ -366,7 +366,7 @@ class HrAttendanceDetail(models.Model):
|
||||
employee_list.append(resource_id.employee_id.id)
|
||||
if employee.id not in employee_list:
|
||||
# 判断是否工作日
|
||||
if not self._process_shift_days(current_data):
|
||||
if self._process_shift_days(current_data):
|
||||
return is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card, is_no_card
|
||||
|
||||
is_tianhe_property = employee.company_id.name == "天河物管"
|
||||
|
||||
@@ -178,6 +178,14 @@
|
||||
<field name="state">code</field>
|
||||
<field name="groups_id" eval="[(4, ref('yuthon_hr_attendance.group_he_attendance_sign_manager'))]"/>
|
||||
</record>
|
||||
<record id="update_state" model="ir.actions.server">
|
||||
<field name="name">初始化状态</field>
|
||||
<field name="model_id" ref="yuthon_hr_attendance.model_hr_attendance"/>
|
||||
<field name="binding_model_id" ref="yuthon_hr_attendance.model_hr_attendance"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.update_state()</field>
|
||||
<field name="groups_id" eval="[(4, ref('yuthon_hr_attendance.group_he_attendance_sign_manager'))]"/>
|
||||
</record>
|
||||
<record id="action_update_abnormal_shift" model="ir.actions.server">
|
||||
<field name="name">批量更新班次名称</field>
|
||||
<field name="model_id" ref="yuthon_hr_attendance.model_hr_attendance"/>
|
||||
|
||||
Reference in New Issue
Block a user