!9933 添加功能

Merge pull request !9933 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2026-03-19 09:01:31 +00:00
committed by Gitee
2 changed files with 41 additions and 18 deletions
+32 -14
View File
@@ -552,26 +552,44 @@ class SoongWorkflowMixin(models.AbstractModel):
btn for btn in next_node.button_ids
if btn.name == '结束'
]
has_visible_transfer_btn = True
for btn in transfer_buttons:
if btn.is_review_invisible:
domain = eval(btn.invisible_expression)
expression_result = self.search(domain)
has_self_in_result = self.id in expression_result.ids
if not end_buttons:
has_visible_transfer_btn = False
has_visible_end_btn = False
# ========== 第一步:判断转交按钮(transfer_buttons)是否可见 ==========
if transfer_buttons:
for btn in transfer_buttons:
if btn.is_review_invisible:
# 解析隐藏表达式,判断当前记录是否在表达式结果中
domain = eval(btn.invisible_expression)
expression_result = self.search(domain)
has_self_in_result = self.id in expression_result.ids
# 转交按钮可见条件:表达式结果包含当前记录
if has_self_in_result:
has_visible_transfer_btn = True
break
else:
has_visible_transfer_btn = False
break # 找到可见按钮,终止循环
else:
# 无隐藏控制,转交按钮默认可见
has_visible_transfer_btn = True
else:
has_visible_transfer_btn = True
break # 找到可见按钮,终止循环
# ========== 第二步:判断结束按钮(end_buttons)是否可见 ==========
if end_buttons:
for btn in end_buttons:
if btn.is_review_invisible:
# 解析隐藏表达式,判断当前记录是否在表达式结果中
domain = eval(btn.invisible_expression)
expression_result = self.search(domain)
has_self_in_result = self.id in expression_result.ids
# 结束按钮可见条件:表达式结果包含当前记录
if has_self_in_result:
has_visible_end_btn = True
break # 找到可见按钮,终止循环
else:
# 无隐藏控制,结束按钮默认可见
has_visible_end_btn = True
break # 找到可见按钮,终止循环
if not has_visible_transfer_btn:
if not has_visible_transfer_btn and not has_visible_end_btn:
skipped_node_names.append(next_node.name)
_logger.info(f"跳过节点: {next_node.name},无可见的转交按钮")
_logger.info(f"跳过节点: {next_node.name},转交按钮和结束按钮均不可见")
# 更新索引
index = state_list.index(matched_key)
@@ -260,12 +260,14 @@ class SoongWorkflowCommentWizard(models.TransientModel):
button_priority_list = ["分发", "下发", "转交", "结束"]
button = False
if node.button_ids:
found_target_btn = False
for btn_name in button_priority_list:
for btn in node.button_ids:
if btn.name == btn_name: # 匹配优先级按钮名称
for btn in sorted(node.button_ids, key=lambda x: x.sequence):
if btn.name == btn_name:
is_in_scope = True
if not btn.is_review_invisible:
button = btn
found_target_btn = True
break
if btn.is_review_invisible:
domain = eval(btn.invisible_expression)
@@ -273,9 +275,12 @@ class SoongWorkflowCommentWizard(models.TransientModel):
matched = model.search(domain + [('id', '=', record_id.id)])
is_in_scope = bool(matched)
if is_in_scope:
target_btn = btn
button = target_btn
button = btn
found_target_btn = True
break
if found_target_btn:
break
if not button:
return self.env['hr.employee']