Merge pull request !825 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2024-12-18 10:09:02 +00:00
committed by Gitee
2 changed files with 94 additions and 89 deletions
@@ -48,6 +48,7 @@
<field name="work_time_type" optional="hidden"/>
<field name="check_in" optional="show" widget="time"/>
<field name="check_out" optional="show" widget="time"/>
<field name="shift_id" optional="show"/>
<field name="shift_name" optional="show"/>
<field name="is_approval" column_invisible="1"/>
<button name="button_leave" type="object" string="请假" class="oe_highlight"
@@ -81,6 +82,7 @@
<field name="noon_duty" optional="show" widget="time"/>
<field name="night_duty" optional="show" widget="time"/>
<field name="check_out" optional="show" widget="time"/>
<field name="shift_id" optional="show"/>
<field name="shift_name" optional="show"/>
<field name="is_approval" column_invisible="1"/>
<button name="button_leave" type="object" string="请假" class="oe_highlight"
@@ -113,6 +115,7 @@
<field name="check_in" optional="show" widget="time"/>
<field name="noon_duty" optional="show" widget="time"/>
<field name="check_out" optional="show" widget="time"/>
<field name="shift_id" optional="show"/>
<field name="shift_name" optional="show"/>
<field name="is_approval" column_invisible="1"/>
<button name="button_leave" type="object" string="请假" class="oe_highlight"
@@ -145,6 +148,7 @@
<field name="check_in" optional="show" widget="time"/>
<field name="noon_duty" optional="show" widget="time"/>
<field name="check_out" optional="show" widget="time"/>
<field name="shift_id" optional="show"/>
<field name="shift_name" optional="show"/>
<field name="is_approval" column_invisible="1"/>
<button name="button_leave" type="object" string="请假" class="oe_highlight"
+90 -89
View File
@@ -266,96 +266,97 @@ class HrAttendanceDetail(models.Model):
exception_type = data.get("exception_type", "")
will_datetime_start = checkin_time.replace(hour=min_hour, minute=min_minute)
will_datetime_end = checkin_time.replace(hour=max_hour, minute=max_minute)
# if not hr_employee_obj.default_planning_role_id:
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
if not hr_employee_obj.default_planning_role_id:
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
elif hr_employee_obj.default_planning_role_id.name == '保安部':
current_datetime_start = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.min)
current_datetime_end = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.max)
planning_slot_id = self.env['planning.slot'].search([('resource_id', '=', hr_employee_obj.resource_id.id),
('start_datetime', '>=', current_datetime_start),
('start_datetime', '<=', current_datetime_end)])
if planning_slot_id:
attendance_obj = self.env['hr.attendance'].sudo().create({
'employee_id': hr_employee_obj.id,
"userid": userid,
"current_data": current_data,
"shift_id": planning_slot_id.id,
"attendance_type": "wx_work"
})
elif checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and exception_type != "未打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and exception_type != "未打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif checkin_time and exception_type != "未打卡" and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_in_time": sch_checkin_time,
"check_in": checkin_time,
"is_late_card": checkin_time > will_datetime_start,
})
elif checkin_time and exception_type != "未打卡" and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"sch_check_out_time": sch_checkin_time,
"check_out": checkin_time,
"is_early_card": will_datetime_end > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# else:
# current_datetime_start = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.min)
# current_datetime_end = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.max)
# planning_slot_id = self.env['planning.slot'].search([('resource_id', '=', hr_employee_obj.resource_id.id),
# ('start_datetime', '>=', current_datetime_start),
# ('start_datetime', '<=', current_datetime_end)])
# if planning_slot_id:
# if planning_slot_id.department_id.name == '保安部':
# attendance_obj = self.env['hr.attendance'].sudo().create({
# 'employee_id': hr_employee_obj.id,
# "userid": userid,
# "current_data": current_data,
# "shift_id": planning_slot_id.id,
# "attendance_type": "wx_work"
# })
# if exception_type != "未打卡":
# if checkin_time and checkin_type == "上班打卡" and not attendance_obj.check_in:
# attendance_obj.sudo().write({
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and checkin_type == "下班打卡" and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and checkin_time < attendance_obj.check_in:
# attendance_obj.sudo().write({
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and checkin_time > attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif checkin_time and not attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_in": checkin_time,
# "is_late_card": checkin_time > planning_slot_id.start_datetime,
# })
# elif checkin_time and attendance_obj.check_in and not attendance_obj.check_out:
# attendance_obj.sudo().write({
# "check_out": checkin_time,
# "is_early_card": planning_slot_id.end_datetime > checkin_time,
# })
# elif attendance_obj.is_early_card or attendance_obj.is_late_card:
# attendance_obj.sudo().write({"is_abnormal": True})
if exception_type != "未打卡":
if checkin_time and checkin_type == "上班打卡" and not attendance_obj.check_in:
attendance_obj.sudo().write({
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and checkin_type == "下班打卡" and not attendance_obj.check_out:
attendance_obj.sudo().write({
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.check_in and checkin_time and checkin_type == "上班打卡" and checkin_time < attendance_obj.check_in:
attendance_obj.sudo().write({
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif attendance_obj.check_out and checkin_time and checkin_type == "下班打卡" and checkin_time > attendance_obj.check_out:
attendance_obj.sudo().write({
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif checkin_time and not attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"check_in": checkin_time,
"is_late_card": checkin_time > planning_slot_id.start_datetime,
})
elif checkin_time and attendance_obj.check_in and not attendance_obj.check_out:
attendance_obj.sudo().write({
"check_out": checkin_time,
"is_early_card": planning_slot_id.end_datetime > checkin_time,
})
elif attendance_obj.is_early_card or attendance_obj.is_late_card:
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# elif planning_slot_id.department_id.name == '工程部':
# attendance_obj = self.env['hr.attendance'].sudo().create({
# 'employee_id': hr_employee_obj.id,