添加功能
This commit is contained in:
@@ -87,7 +87,9 @@ class SoongWorkflowRecord(models.Model):
|
||||
store=False
|
||||
)
|
||||
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company',search='_search_part_of_company')
|
||||
is_done = fields.Boolean(string="已办", default=True, compute='_compute_is_done',search='_search_is_done')
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company',
|
||||
search='_search_part_of_company')
|
||||
|
||||
# 办结时间(上一节点的结束时间)
|
||||
node_update_time = fields.Datetime(string="办结时间")
|
||||
@@ -128,61 +130,6 @@ class SoongWorkflowRecord(models.Model):
|
||||
_logger.warning(f"Failed to get urgency_level from {record.res_model}: {e}")
|
||||
record.urgency_level = 'normal'
|
||||
|
||||
@api.depends_context('uid', 'company')
|
||||
@api.depends('company_id', 'workflow_id', 'users_ids') # 新增依赖字段
|
||||
def _compute_is_company(self):
|
||||
current_user = self.env.user
|
||||
is_system_admin = current_user.has_group('base.group_system') or current_user.has_group('base.group_admin')
|
||||
active_company_ids = self.env.companies
|
||||
special_workflow_names = ['文件处理', '文件处理(子企业)']
|
||||
for record in self:
|
||||
if record.workflow_id and record.workflow_id.name in special_workflow_names:
|
||||
if is_system_admin:
|
||||
record.is_company = True
|
||||
else:
|
||||
record.is_company = current_user in record.users_ids
|
||||
else:
|
||||
# 走原有的company_id逻辑
|
||||
record.is_company = record.company_id in active_company_ids
|
||||
|
||||
def _search_part_of_company(self, operator, value):
|
||||
special_workflow_names = ['文件处理', '文件处理(子企业)']
|
||||
special_records = self.search([('workflow_id.name', 'in', special_workflow_names)]).ids
|
||||
normal_records = self.search([('workflow_id.name', 'not in', special_workflow_names)]).ids
|
||||
|
||||
current_user = self.env.user
|
||||
is_system_admin = current_user.has_group('base.group_system') or current_user.has_group('base.group_admin')
|
||||
current_user_id = current_user.id
|
||||
|
||||
domain = []
|
||||
if special_records:
|
||||
if is_system_admin:
|
||||
special_domain = [('id', 'in', special_records)]
|
||||
else:
|
||||
if value:
|
||||
if operator == "=":
|
||||
special_domain = [('id', 'in', special_records), ("users_ids", "in", [current_user_id])]
|
||||
else:
|
||||
special_domain = [('id', 'in', special_records), ("users_ids", "not in", [current_user_id])]
|
||||
else:
|
||||
if operator == "=":
|
||||
special_domain = [('id', 'in', special_records), ("users_ids", "not in", [current_user_id])]
|
||||
else:
|
||||
special_domain = [('id', 'in', special_records), ("users_ids", "in", [current_user_id])]
|
||||
domain.append(special_domain)
|
||||
|
||||
if normal_records:
|
||||
company_ids = self.env.companies.ids
|
||||
if not value:
|
||||
operator = '!=' if operator == '=' else '='
|
||||
if operator == '=':
|
||||
normal_domain = [('id', 'in', normal_records), ('company_id', 'in', company_ids)]
|
||||
else:
|
||||
normal_domain = [('id', 'in', normal_records), ('company_id', 'not in', company_ids)]
|
||||
domain.append(normal_domain)
|
||||
|
||||
return ['|'] + domain if domain else []
|
||||
|
||||
@api.depends('employee_ids', 'soong_state', 'reclaim_state')
|
||||
def _compute_is_to_do(self):
|
||||
current_uid = self.env.user.id
|
||||
@@ -214,6 +161,50 @@ class SoongWorkflowRecord(models.Model):
|
||||
domain = []
|
||||
return domain
|
||||
|
||||
@api.depends('employee_ids', 'soong_state', 'reclaim_state')
|
||||
def _compute_is_done(self):
|
||||
current_uid = self.env.user.id
|
||||
for record in self:
|
||||
record.is_done = False
|
||||
condition1 = record.soong_state = 'done'
|
||||
condition2 = not record.reclaim_state
|
||||
condition3 = False
|
||||
if record.users_ids:
|
||||
condition3 = current_uid in record.users_ids.ids
|
||||
if condition1 and condition2 and condition3:
|
||||
record.is_done = True
|
||||
|
||||
def _search_is_done(self, operator, value):
|
||||
current_uid = self.env.user.id
|
||||
base_domain = [
|
||||
('soong_state', '=', 'done'),
|
||||
('reclaim_state', '=', False),
|
||||
('users_ids', 'in', current_uid)
|
||||
]
|
||||
if (operator == '=' and value) or (operator == '!=' and not value):
|
||||
domain = base_domain
|
||||
elif (operator == '=' and not value) or (operator == '!=' and value):
|
||||
domain = ['!'] + base_domain
|
||||
else:
|
||||
domain = []
|
||||
return domain
|
||||
|
||||
@api.depends_context('uid', 'company')
|
||||
@api.depends('company_id')
|
||||
def _compute_is_company(self):
|
||||
active_company_ids = self.env.companies
|
||||
for employee in self:
|
||||
employee.is_company = employee.company_id in active_company_ids
|
||||
|
||||
def _search_part_of_company(self, operator, value):
|
||||
company_ids = self.env.companies.ids
|
||||
if not value:
|
||||
operator = '!=' if operator == '=' else '='
|
||||
if operator == '=':
|
||||
return [('company_id', 'in', company_ids)]
|
||||
else:
|
||||
return [('company_id', 'not in', company_ids)]
|
||||
|
||||
@api.depends_context('uid', 'company')
|
||||
@api.depends('department_id', 'employee_ids')
|
||||
def _compute_part_of_department(self):
|
||||
|
||||
@@ -449,9 +449,7 @@
|
||||
<field name="context">{'header_search_default_approve_state': 1, 'header_search_default_to_do':1,
|
||||
'check_employee': 1}
|
||||
</field>
|
||||
<field name="domain">[('users_ids', 'in', uid), ('reclaim_state', '=', False), ('soong_state', 'in',
|
||||
['done', 'active']), ('is_company', '=', True)]
|
||||
</field>
|
||||
<field name="domain">[('is_done', '=', True)]</field>
|
||||
<field name="search_view_id" ref="soong_workflow_record_search1"/>
|
||||
<field name="view_id" ref="soong_workflow_record_done_tree"/>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user