From c773bec4cbc4b13cc4337bd586772acc9ab5e243 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, 2 Sep 2026 11:20:34 +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 --- .../many2many_tags/many2many_tags_field.js | 43 +++++++++----- .../views/res_company_views.xml | 56 +++++++++++++++++-- 2 files changed, 79 insertions(+), 20 deletions(-) diff --git a/many2many_tags_preview/static/src/many2many_tags/many2many_tags_field.js b/many2many_tags_preview/static/src/many2many_tags/many2many_tags_field.js index 2f40e6e65..b7e688907 100644 --- a/many2many_tags_preview/static/src/many2many_tags/many2many_tags_field.js +++ b/many2many_tags_preview/static/src/many2many_tags/many2many_tags_field.js @@ -11,19 +11,19 @@ patch(Many2ManyTagsFieldColorEditable, { }); patch(Many2ManyTagsFieldColorEditable.prototype, { async onBadgeClick(ev, record) { - if (!this.props.canEditColor) { - const context = record.evalContext?.context || {}; + const context = record.evalContext?.context || {}; + // 优先处理 open_form_view:显式指定打开某个表单视图(如分公司标签), + // 不受 canEditColor 颜色弹窗逻辑影响,确保点击直达指定表单。 + if (context.open_form_view) { let viewId = false; - if (context.open_form_view) { - try { - viewId = await this.orm.call( - "ir.ui.view", - "get_view_id_from_xmlid", - [context.open_form_view] - ); - } catch (error) { - console.error("获取指定 XML ID 的视图 ID 失败:", context.open_form_view, error); - } + try { + viewId = await this.orm.call( + "ir.ui.view", + "get_view_id_from_xmlid", + [context.open_form_view] + ); + } catch (error) { + console.error("获取指定 XML ID 的视图 ID 失败:", context.open_form_view, error); } this.env.services.action.doAction({ type: "ir.actions.act_window", @@ -33,7 +33,22 @@ patch(Many2ManyTagsFieldColorEditable.prototype, { views: [[viewId, "form"]], target: "new", context: { - edit: false, + edit: true, + create: false + }, + }); + return; + } + if (!this.props.canEditColor) { + this.env.services.action.doAction({ + type: "ir.actions.act_window", + name: record?.data?.display_name, + res_model: this.relation, + res_id: record.resId, + views: [[false, "form"]], + target: "new", + context: { + edit: true, create: false }, }); @@ -94,7 +109,7 @@ patch(Many2ManyTagsField.prototype, { views: [[viewId, "form"]], target: "new", context: { - edit: false, + edit: true, create: false }, }); diff --git a/yuthon_hr_employee/views/res_company_views.xml b/yuthon_hr_employee/views/res_company_views.xml index d170f9031..7b40aae1d 100644 --- a/yuthon_hr_employee/views/res_company_views.xml +++ b/yuthon_hr_employee/views/res_company_views.xml @@ -1,14 +1,58 @@ - + + yuthon.hr.employee.res.company.form res.company - + 50 - - - 0 - 0 +
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + yuthon.hr.employee.res.company.tree.ctx + res.company + + + + {'open_form_view': 'yuthon_hr_employee.res.company.form'}