!8851 考勤详情打不开处理

Merge pull request !8851 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-02-10 02:09:27 +00:00
committed by Gitee
+11 -14
View File
@@ -650,15 +650,10 @@ class HrAttendance(models.Model):
template_domain.append(('department_id', 'in', all_dept_ids))
template = self.env['planning.slot.template'].search(template_domain, limit=1)
if not template:
role_templates = [
{'role_name': '厨卫(集团)', 'template': None},
{'role_name': '项目运营岗', 'template': None}
]
template = self.env['planning.slot.template'].search([('role_id.name', '=', '集团行政')], limit=1)
role_templates = [{'role_name': '厨卫(集团)', 'template': None}, {'role_name': '项目运营岗', 'template': None}]
for item in role_templates:
item['template'] = self.env['planning.slot.template'].search(
[('role_id.name', '=', item['role_name'])], )
item['template'] = self.env['planning.slot.template'].search([('role_id.name', '=', item['role_name'])], )
for item in role_templates:
if item['template']:
employee_ids = item['template'].role_id.resource_ids.employee_id.ids or []
@@ -666,14 +661,8 @@ class HrAttendance(models.Model):
if employee_id.id in employee_list:
template = item['template']
break
if not template:
template = self.env['planning.slot.template'].search(
[('role_id.name', '=', '集团行政')],
limit=1
)
next_day = current_date + timedelta(days=1)
start_datetime = datetime.combine(current_date, datetime.min.time()) - timedelta(hours=8)
# 3. 确定有效上下班时间
check_out_end = self.float_to_datetime(current_date, template.check_out_end)
if template.day2 == '次日':
check_out_end = self.float_to_datetime(next_day, template.check_out_end)
@@ -682,6 +671,12 @@ class HrAttendance(models.Model):
('checkin_time', '>=', start_datetime),
('checkin_time', '<', check_out_end - timedelta(hours=8))
]
if '行政' in template.display_name:
domain = [
('employee_id', '=', employee_id.id),
('checkin_time', '>=', current_date),
('checkin_time', '<', next_day)
]
attendance_records = self.env['hr.attendance.detail'].search(domain)
if attendance_records:
action = {
@@ -689,10 +684,12 @@ class HrAttendance(models.Model):
'type': 'ir.actions.act_window',
'res_model': 'hr.attendance.detail',
'view_mode': 'tree,form',
'target': 'new',
'domain': domain,
}
return action
else:
_logger.info(f"当前过滤条件为开始日期-----{start_datetime}结束日期------{check_out_end - timedelta(hours=8)}")
raise ValidationError("该员工当天没有考勤记录!")
def float_to_datetime(self, base_date, hour_float):