how-to-create-pivot-view-in-odoo.png
Blogger_637006570941813163.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 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.


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


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="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. 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="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>
With the help of the above code, you can easily generate a pivot view.




cybrosys youtube

Comments

0


Leave a comment

 
Calicut

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

London

Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom

Kochi

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

Bangalore

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

Send Us A Message