For seamless management of everyday business operations, Odoo comes with variant views supporting the users. The different kind of views, helps the user to sort the relevant and highly significant data.
Odoo provides a wide variety of views, which help the user to manage each and every operation. Here we are going to discuss the odoo pivot view which helps the end-user to analyze the operations and which have different options to filter reports based on specific fields used in the model and also allow us to download the filtered report. The view of a pivot view looks like the below image.
In this view, we can see the + button. When you click the button there you can get all the fields related to that model. If you select one of the fields, you get the filtered report display based on the selected field.
Now I will show you how to create a pivot view.
<menuitem name="Customer Report" id="menu_report_customer" parent="sale.menu_sale_report" action="action_view_pivot" sequence="5"/>
Above code, menuitem name will be the button name, parent it will decide where you want to view that button and When you click the button Customer Report it will call the action ‘action_view_pivot’.action which are used for rendering views in odoo. In such a way that as in the case of our action we are only considering the pivot view.in the below action you can see the action code.
<record id="action_view_pivot" model="ir.actions.act_window">
<field name="name">View Pivot</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Enter the target
In ‘ir.ui.view’ a type is specified there, one is the row and the other is col, in a row it will create row-wise groups and in the col, it creates the column-wise group. Pivot view generates a table dynamically when row or column changes. Each time the user changes the field in row or column it will call the corresponding SQL queries and generated table.
<record id="view_pivot" model="ir.ui.view">
<field name="arch" type="xml">
<pivot string="Pivot View">
<field name="name" type="row"/>
With the help of the above code, you can easily generate a pivot view.