From 77afd2833f975ff9cd0975277136fa6d7f5d977f Mon Sep 17 00:00:00 2001 From: "Xavier Bol (xbo)" Date: Mon, 9 Oct 2023 17:00:03 +0200 Subject: [PATCH] [IMP] hr_org_chart: add stat button in hr.employee form view This commit adds a stat button in the form view `hr.employee` model to be able to go to the org chart and visualize the hierarchy of the current record displayed in the form view. The action used inside that stat button cannot have a domain to filter the result to just have the current record since the user will not be able to search into the search view. The alternative is to use a context used inside the hierarchy view to add the domain only when we load the view (as it is a default domain). task-3376776 --- .../static/src/views/hierarchy/hierarchy_model.js | 7 ++++++- addons/hr_org_chart/views/hr_views.xml | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/hr_org_chart/static/src/views/hierarchy/hierarchy_model.js b/addons/hr_org_chart/static/src/views/hierarchy/hierarchy_model.js index 6180b337daa..e0a35dcd353 100644 --- a/addons/hr_org_chart/static/src/views/hierarchy/hierarchy_model.js +++ b/addons/hr_org_chart/static/src/views/hierarchy/hierarchy_model.js @@ -651,7 +651,12 @@ export class HierarchyModel extends Model { if ("domain" in params) { config.domain = params.domain; if (!params.domain.length) { - config.domain = this.defaultDomain; + if (config.context.hierarchy_res_id) { + config.domain = [["id", "=", config.context.hierarchy_res_id]]; + delete config.context.hierarchy_res_id; // just needed for the first load. + } else { + config.domain = this.defaultDomain; + } } } return config; diff --git a/addons/hr_org_chart/views/hr_views.xml b/addons/hr_org_chart/views/hr_views.xml index 052d1caeef9..7c73e36be88 100644 --- a/addons/hr_org_chart/views/hr_views.xml +++ b/addons/hr_org_chart/views/hr_views.xml @@ -24,6 +24,9 @@ hr.employee + +