From f197057db6ca9af519a3a8d52bba5367e57588ee 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: Wed, 19 Aug 2026 17:12:29 +0800 Subject: [PATCH] =?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_mixin.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/soong_workflow/models/soong_workflow_mixin.py b/soong_workflow/models/soong_workflow_mixin.py index 7a9720ad8..10c0e9d3a 100644 --- a/soong_workflow/models/soong_workflow_mixin.py +++ b/soong_workflow/models/soong_workflow_mixin.py @@ -1279,7 +1279,24 @@ class SoongWorkflowMixin(models.AbstractModel): ] # 如果有角色条件,添加到可见性条件中 if role_domain: - allowed_user_ids = self.env['res.users'].search(role_domain).ids + allowed_user_ids = set(self.env['res.users'].search(role_domain).ids) + # 委托补充:角色组内的委托人(如部门经理A)若把流程委托给被委托人(b), + # 被委托人本人未必在该角色组内,也应能看到/操作该按钮 + entrust_all = self.env['ir.model'].sudo().search( + [('model', '=', 'entrust.all')], limit=1) + model_rec = self.env['ir.model'].sudo().search( + [('model', '=', model)], limit=1) if model else None + entrusts = self.env['soong.workflow.entrust'].sudo().search([ + ('is_enable', '=', True), + ('entrust_user_id', 'in', list(allowed_user_ids)), + ]) + for ent in entrusts: + ent_model_ids = ent.model_ids.ids + in_scope = (entrust_all and entrust_all.id in ent_model_ids) or ( + model_rec and model_rec.id in ent_model_ids) + if in_scope and ent.entrust_user_id2: + allowed_user_ids.add(ent.entrust_user_id2.id) + allowed_user_ids = list(allowed_user_ids) invisible += f" or uid not in {allowed_user_ids}" # 如果有隐藏条件的话,启用隐藏 if button.is_review_invisible and button.invisible_expression: