Enable Dark Mode!
how-to-create-pivot-view-in-odoo.png
By: Cirin C Baby

How to Create Pivot View in Odoo 13

Technical

For seamless management of everyday business operations, Odoo comes with variant views supporting the users. The different kinds of views, help 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 window of a pivot view is as shown in the following image.

how-to-create-pivot-view-in-odoo-cybrosys


In this view, we can see the + button next to the total option which will depict you with all the fields related to that model. Furthermore, 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, use the following code for it.


<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 in the code will decide where you want to view that button and  when you click the button Customer Report will call the action ‘action_view_pivot’.action which is 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 following code you can see the action code.

<record id="action_view_pivot" model="ir.actions.act_window">
      <field name="name">View Pivot</field>
      <field name="res_model">res.partner</field>
      <field name="view_mode">pivot</field>
      <field name="domain">[]</field>
      <field name="help" type="html">
          <p class="oe_view_nocontent_create">Enter the target
          </p>
      </field>
  </record>

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. Furthermore, the pivot view generates a table dynamically when a row or column changes. Each time the user changes the field in a row or column it will call the corresponding SQL queries and generated table. The following code will help you to generate a pivot view with ease.

<record id="view_pivot" model="ir.ui.view">
  <field name="name">pivot</field>
  <field name="model">res.partner</field>
  <field name="arch" type="xml">
      <pivot string="Pivot View">
           <field name="name" type="row"/>
      </pivot>
   </field>
</record>
Among all the views available in Odoo pivot view is the one of the informative views as well as the one that can be configured to derive the required data based on various filters.


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



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

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

location

Kochi

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

location

Bangalore

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

Send Us A Message