Enable Dark Mode!
By: Cybrosys Technologies

How to Create a Hierarchical View in Odoo 17

Technical Odoo 17

Odoo is recognized globally as one of the most user-friendly business management software packages, essential for the effective management of business departments. In addition, the open-source ERP has numerous management modules connected with it, including CRM, Sales, Purchase, HR, Accounting, Point of Sale, and many more, to streamline a significant portion of corporate processes.

Odoo programs contain data as objects, which are represented by Odoo views. Many views that allow various forms of data representation are supported by Odoo, including the tree view, list view, kanban view, cohort view, pivot view, and calendar view. The hierarchical view, introduced in Odoo 17, offers a structured and organized representation of data, enhancing the platform's capabilities for effective information visualization.

This blog discusses how to create a simple hierarchical view in Odoo 17.

Hierarchical view:


Define the Python Model as shown below:

First, we have to create a new model eg: ‘department.details’.

Here is the code for creating a department model and making sure that parent_id and child_ids model as ‘department.details’.

    _name = 'department.details'
    _description = 'create a new model for hierarchy'
    _rec_name = 'department'
    department = fields.Char()
    parent_id = fields.Many2one("department.details")
   child_ids = fields.One2many("department.details",'parent_id')

Define the XML view as shown below:

To define the XML view, use the following command:

First, we have to create an action for this model:

<record id="department_details_action" model="ir.actions.act_window">
        <field name="name">Department details</field>
        <field name="res_model">department.details</field>
        <field name="view_mode">tree,form,kanban,hierarchy</field>

XML code for hierarchical view:

<record id="department_details_view_hierarchy" model="ir.ui.view">
        <field name="name">department.details.view.hierarchy</field>
        <field name="model">department.details</field>
        <field name="arch" type="xml">
            <hierarchy child_field="child_ids"
                <field name="department"/>
                    <t t-name="hierarchy-box">
                        <div t-attf-class="o_hierarchy_node_header d-flex justify-content-center pb-4"
                        <div class="o_hierarchy_node_body d-flex flex-column text-center">
                            <div class="w-100 position-relative">
                                <field class="fw-bold" name="department"/><br/>

Add Security:

Add security also as follows:


Here, we can see the output as follows:


The advanced hierarchical view functionality within the Odoo platform contributes to the streamlined operation of various menu functions, enhancing the platform's effectiveness in business management.

To read more about the HR organizational chart in Odoo 16, refer to our blog HR Organizational Chart in Odoo 16

If you need any assistance in odoo, we are online, please chat with us.



There is error : ValueError: Wrong value for ir.ui.view.type: 'hierarchy' it's may be dependency issue




Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message