添加功能
This commit is contained in:
@@ -245,13 +245,22 @@ class HrAttendanceDetail(models.Model):
|
||||
is_resource_user = True if employee.id in resource_user_ids else False
|
||||
# 哺乳人员
|
||||
suckling_employees = employee.resource_calendar_id.breastfeeding_holiday_ids.mapped('employee_id')
|
||||
|
||||
def get_all_upper_depts(dept):
|
||||
"""递归获取部门及其所有上级部门的ID列表"""
|
||||
"""递归获取部门及其所有上级部门的ID列表、名称列表"""
|
||||
dept_ids = [dept.id]
|
||||
dept_names = [dept.name]
|
||||
if dept.parent_id:
|
||||
dept_ids.extend(get_all_upper_depts(dept.parent_id))
|
||||
return dept_ids
|
||||
all_dept_ids = get_all_upper_depts(employee.department_id)
|
||||
upper_ids, upper_names = get_all_upper_depts(dept.parent_id)
|
||||
dept_ids.extend(upper_ids)
|
||||
dept_names.extend(upper_names)
|
||||
return dept_ids, dept_names
|
||||
|
||||
# 获取所有层级部门ID和部门名称
|
||||
all_dept_ids, all_dept_names = get_all_upper_depts(employee.department_id)
|
||||
|
||||
# 打印所有层级的部门名称
|
||||
print("当前员工所属所有层级部门名称:", all_dept_names)
|
||||
|
||||
if is_resource_user:
|
||||
attendance = self.env['hr.attendance'].search(
|
||||
@@ -284,9 +293,6 @@ class HrAttendanceDetail(models.Model):
|
||||
template_domain.append(('planning_name', '=', planning_name))
|
||||
template_domain.append(('department_id', 'in', all_dept_ids))
|
||||
template = self.env['planning.slot.template'].search(template_domain, limit=1)
|
||||
# 如果模板里面找不到这个人 则还是往下判断(模板为空)
|
||||
if employee.id not in template.role_id.resource_ids.employee_id.ids:
|
||||
template = None
|
||||
|
||||
if not template:
|
||||
role_templates = [
|
||||
|
||||
Reference in New Issue
Block a user