[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
This commit is contained in:
Xavier Bol (xbo)
2023-10-16 08:17:31 +02:00
parent 6df589a73b
commit 77afd2833f
2 changed files with 9 additions and 1 deletions
@@ -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;
+3
View File
@@ -24,6 +24,9 @@
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button name="%(hr_org_chart.action_hr_employee_org_chart)d" string="Org Chart" type="action" context="{'hierarchy_res_id': id}" invisible="not parent_id and not child_ids"/>
</xpath>
<div id="o_work_employee_main" position="after">
<div id="o_employee_right" class="col-lg-4 px-0 ps-lg-5 pe-lg-0">
<separator string="Organization Chart"/>