From b821e5c3c71572cb4136098f3c3275ce4a46b27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Thu, 23 Apr 2026 19:22:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- soong_workflow/models/soong_workflow_node.py | 1 + .../views/soong_workflow_node_views.xml | 1 + .../wizard/soong_workflow_comment_wizard.py | 34 ++++++++++++++++++- yuthon_notice/models/yuthon_notice.py | 1 - 4 files changed, 35 insertions(+), 2 deletions(-) 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..dcd9a548c 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, From 99740dc2cf0d7992036579e74233019ce3c7aa25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Thu, 23 Apr 2026 19:23:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- soong_workflow/wizard/soong_workflow_comment_wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py index dcd9a548c..7ada98a92 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard.py +++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py @@ -241,7 +241,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): 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}】,不可选择必经节点之后的流程节点!") + raise UserError(f"节点【{first_mandatory_node.name}】是必经节点,不可选择必经节点之后的流程节点!") if not record.trans_link_id: continue