diff --git a/soong_workflow/models/soong_workflow_node.py b/soong_workflow/models/soong_workflow_node.py
index 71ffa25c7..0e06899e9 100644
--- a/soong_workflow/models/soong_workflow_node.py
+++ b/soong_workflow/models/soong_workflow_node.py
@@ -107,6 +107,7 @@ class SoongWorkflowNode(models.Model):
('next', '跳过下一个相同人员节点'),
('prev', '跳过上一个相同人员节点'),
], string='相同人员节点处理', default='none')
+ is_mandatory_node = fields.Boolean(string="必经节点", default=False)
@api.onchange("is_apostille")
def onchange_is_apostille(self):
diff --git a/soong_workflow/views/soong_workflow_node_views.xml b/soong_workflow/views/soong_workflow_node_views.xml
index 11a668c0f..82f6f1de2 100644
--- a/soong_workflow/views/soong_workflow_node_views.xml
+++ b/soong_workflow/views/soong_workflow_node_views.xml
@@ -17,6 +17,7 @@
+
diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py
index 43a71bdfc..7ada98a92 100644
--- a/soong_workflow/wizard/soong_workflow_comment_wizard.py
+++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py
@@ -206,13 +206,45 @@ class SoongWorkflowCommentWizard(models.TransientModel):
@api.onchange('trans_link_id')
def onchange_trans_employee_ids(self):
for record in self:
+ record_id = self.env[record.res_model].browse(record.res_id) if record.res_model and record.res_id else None
+ ctx_links = self.env.context.get('all_workflow_links', [])
+ all_links = self.env['trans.link'].browse(ctx_links) if isinstance(ctx_links, (list, tuple)) else ctx_links
+
+ valid_links = all_links - record.invalid_link_ids
+
record.is_selection = False
record.is_this_company = True
if record.node_btn_id.employee_ids and record.node_btn_id.is_carbon_copy:
record.circulated_employee_ids = record.node_btn_id.employee_ids
+
+ if not record_id or not record_id.workflow_id:
+ continue
+ # 排除规则:存在 node_btn_name == '1' 直接放行不限制
+ has_exclude_log = record_id.log_ids.filtered(lambda l: l.node_btn_name == '1')
+ if has_exclude_log:
+ continue
+ # 1. 拿到所有必经节点
+ mandatory_nodes = record_id.workflow_id.node_ids.filtered(lambda n: n.is_mandatory_node)
+ if not mandatory_nodes:
+ return
+ # 取第一个必经节点
+ first_mandatory_node = mandatory_nodes[0]
+ # 2. 只允许选择:顺序 <= 必经节点的链接
+ allow_links = self.env['trans.link']
+ for link in valid_links:
+ link_node = record_id.workflow_id.node_ids.search([
+ ('name', '=', link.name),
+ ('workflow_id', '=', record_id.workflow_id.id)
+ ], limit=1)
+ if link_node and link_node.sequence <= first_mandatory_node.sequence:
+ allow_links |= link
+
+ if record.trans_link_id and record.trans_link_id not in allow_links:
+ record.trans_link_id = False
+ raise UserError(f"节点【{first_mandatory_node.name}】是必经节点,不可选择必经节点之后的流程节点!")
+
if not record.trans_link_id:
continue
- record_id = self.env[record.res_model].browse(record.res_id) if record.res_model and record.res_id else None
for link in record.trans_link_id:
employee_user_role_ids = self.env['hr.employee']
if link.name == '印章管理员':
diff --git a/yuthon_notice/models/yuthon_notice.py b/yuthon_notice/models/yuthon_notice.py
index b60847d06..02ee5b840 100644
--- a/yuthon_notice/models/yuthon_notice.py
+++ b/yuthon_notice/models/yuthon_notice.py
@@ -237,7 +237,6 @@ class YuthonNotice(models.Model):
('notice_code', '=', self.code),
('employee_id', '=', emp_id)
], limit=1)
-
if not is_exist:
self.env['yuthon.confirm.users'].sudo().create({
'notice_id': self.id,