Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
Last active August 31, 2024 07:11
Show Gist options
  • Select an option

  • Save sehrishnaz/b8cbadfe3a80f4757a030e234b9b1033 to your computer and use it in GitHub Desktop.

Select an option

Save sehrishnaz/b8cbadfe3a80f4757a030e234b9b1033 to your computer and use it in GitHub Desktop.
Tree Data Structure for Manager Employee Hierarchy
<record id="employee_hierarchy_tree_view" model="ir.ui.view">
<field name="name">hr.employee.hierarchy.tree</field>
<field name="model">hr.employee</field>
<field name="field_parent">child_ids</field>
<field eval="20" name="priority"/>
<field name="arch" type="xml">
<tree string="Employees" toolbar="True">
<field name="name"/>
<field name="company_id"/>
<field name="department_id"/>
<field name="work_phone"/>
<field name="work_email"/>
<field name="job_id"/>
<field name="parent_id" invisible="1"/>
</tree>
</field>
</record>
<!--By using window action-->
<record id="window_action_employee_hierarchy_tree" model="ir.actions.act_window">
<field name="name">Employee Hierarchy Window Action</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.employee</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_type">tree</field>
<field name="view_id" ref="employee_hierarchy_tree_view"/>
</record>
<menuitem name="Employee | Organization Hierarchy" id="menu_employee_hierarchy_for_window_action" action="window_action_employee_hierarchy_tree" sequence="1"/>
<!--By using server action-->
<record id="server_action_employee_hierarchy_tree" model="ir.actions.server">
<field name="name">Employee Hierarchy Server Action</field>
<field name="condition">True</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_hr_employee" />
<field name="state">code</field>
<field name="code">action=self.load_employee_hierarchy(cr, uid, context.get('active_ids', []), context=context)</field>
</record>
<menuitem name="Employee | Organization Hierarchy" id="menu_employee_hierarchy_for_server_action" action="server_action_employee_hierarchy_tree" sequence="1"/>
@etoimene
Copy link

etoimene commented Aug 31, 2024

is triggering an error when I try to create this view.

"Validation Error

Invalid view hr.employee.hierarchy.tree definition in False"
Tried on 16 and 17 CE.
When I remove toolbar="True", I can create a view,
I was not able to find "toolbar" in views architecture documentation.
Any hint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment