添加功能

This commit is contained in:
zhou
2025-05-27 20:33:38 +08:00
parent 4c5da18b7c
commit bb96cb5c77
+14 -1
View File
@@ -53,8 +53,21 @@ class SoongWorkflowRecord(models.Model):
def _compute_part_of_department(self):
user_employee = self._get_valid_employee_for_user()
active_department = user_employee.department_id
parent_department = active_department.parent_id
# 递归获取父部门的所有子部门
def get_all_children(departments):
all_children = self.env['hr.department']
for department in departments:
children = department.child_ids
all_children += children
if children:
all_children += get_all_children(children)
return all_children
# 父部门及其所有子部门
related_departments = parent_department + get_all_children(parent_department)
for employee in self:
employee.member_of_department = employee.department_id == active_department
employee.member_of_department = employee.department_id in related_departments
def _get_valid_employee_for_user(self):
user = self.env.user