!3367 添加功能

Merge pull request !3367 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-06-17 03:00:19 +00:00
committed by Gitee
2 changed files with 20 additions and 16 deletions
@@ -74,7 +74,7 @@
<field name="is_check_out_red" column_invisible="1"/>
<button name="button_controls_wizard" type="object" string="操作" class="oe_highlight" invisible="not (is_abnormal or is_early_card or is_late_card or absenteeism_card or is_no_card)"/>
<button name="button_correct_wizard" type="object" string="修正" class="btn btn-primary" invisible="not (is_abnormal or is_early_card or is_late_card or absenteeism_card or is_no_card)" groups="yuthon_hr_attendance.group_he_attendance_sign_manager"/>
<button name="revoke" type="object" string="撤销" class="btn btn-primary" invisible="not is_check_out_red or is_check_in_red" groups="yuthon_hr_attendance.group_he_attendance_sign_manager"/>
<button name="revoke" type="object" string="撤销" class="btn btn-primary" invisible="not (is_check_out_red or is_check_in_red)" groups="yuthon_hr_attendance.group_he_attendance_sign_manager"/>
<button name="button_source" type="object" string="详情" class="oe_highlight" groups="yuthon_hr_attendance.group_he_attendance_sign_manager"/>
</tree>
</field>
@@ -72,39 +72,43 @@ class AttendanceCorrectWizard(models.TransientModel):
self.attendance_id.write(values)
else:
check_in_start = record.attendance_id.shift_id.template_id.check_in_start
check_out_end = record.attendance_id.shift_id.template_id.check_out_end
date = record.attendance_id.shift_id
shift = self.attendance_id.shift_id
check_in_start = shift.template_id.check_in_start
check_out_end = shift.template_id.check_out_end
# 提取小时和分钟
start_hour = int(check_in_start)
start_minute = int((check_in_start - start_hour) * 60)
end_hour = int(check_out_end)
end_minute = int((check_out_end - end_hour) * 60)
# 从 planning.slot 对象中获取日期
shift_date = shift.start_datetime.date() # 获取班次开始日期
# 拼接成 datetime 对象
start_datetime = datetime.combine(date, datetime.min.time()).replace(
normal_check_in = datetime.combine(shift_date, datetime.min.time()).replace(
hour=start_hour, minute=start_minute, second=0, microsecond=0
)
end_datetime = datetime.combine(date, datetime.min.time()).replace(
) - timedelta(hours=8)
normal_check_out = datetime.combine(shift_date, datetime.min.time()).replace(
hour=end_hour, minute=end_minute, second=0, microsecond=0
)
if record.attendance_id.shift_id.template_id.day2 == '次日':
end_datetime = end_datetime + timedelta(days=1)
) - timedelta(hours=8)
# 如果是次日班次,调整下班时间
if shift.template_id.day2 == '次日':
normal_check_out = normal_check_out + timedelta(days=1)
# 处理上班打卡
if not self.attendance_id.check_in:
values['check_in'] = start_datetime
values['check_in'] = normal_check_in
values['is_check_in_red'] = True
values['is_no_card'] = False
elif self.attendance_id.check_in > start_datetime:
values['check_in'] = start_datetime
elif self.attendance_id.check_in > normal_check_in:
values['check_in'] = normal_check_in
values['is_check_in_red'] = True
values['is_late_card'] = False
# 处理下班打卡
if not self.attendance_id.check_out:
values['check_out'] = end_datetime
values['check_out'] = normal_check_out
values['is_check_out_red'] = True
values['is_no_card'] = False
elif self.attendance_id.check_out < end_datetime:
values['check_out'] = end_datetime
elif self.attendance_id.check_out < normal_check_out:
values['check_out'] = normal_check_out
values['is_check_out_red'] = True
values['is_early_card'] = False
# 应用修改