Odoo 16 Development Book

Pivot view

A Pivot table view is the best tool to calculate and also analyze data. In Odoo, we can create pivot tables for our model so that users get a table structure of all the records.

Let us see how to set the pivot table.

First, we have to create a model, menu, and menu action.

from odoo import models, fields
class ExampleOdoo(models.Model):
    example_field = fields.Char(string="Example Field")
    example_field1 = fields.Many2one('res.users', 'User', required=True)
<record id="action_Example" model="ir.actions.act_window">
                        <field name="name">Example</field>
                        <field name="type">ir.actions.act_window</field>
                        <field name="res_model">example.odoo</field>
                        <field name="view_mode">form,tree,pivot</field>
                    <menuitem id="example_menu"
                            name="Example Odoo"

Then create the pivot view like this.

<record id="example_pivot_view" model="ir.ui.view">
                                <field name="name">example.pivot</field>
                                <field name="model">example.odoo</field>
                                <field name="arch" type="xml">
                                    <pivot string="Project Tasks">
                                        <field name="example_field" type="row"/>
                                        <field name="example_field1" type="col"/>

The output will be

odoo Development


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