Chapter 6 - Odoo 15 Development Book

Pivot view

Odoo supports several views. such as tree view, form view, list view, Kanban view, pivot view, calendar view etc. The pivot view is used to visualize aggregations as a pivot table. Its root element is <pivot>

Let’s create a pivot view:

Created a model book.

class Book(models.Model):
 _name = 'book'
    display_name = fields.Char(string='Name', required=True)
    author = fields.Many2one('res.users', 'Author', required=True)
    sl_no = fields.Char('Sl No', required=True)

Created an action for this model

<record id="action_Book" model="ir.actions.act_window">
    <field name="name">Book</field>
  	<field name="type">ir.actions.act_window</field>
   	<field name="res_model">book</field>
   	<field name="view_mode">tree,form,pivot</field>
</record>

This is the pivot view of this model

<record id="view_book_pivot" model="ir.ui.view">
    <field name="name">book.pivot</field>
    <field name="model">book</field>
    <field name="arch" type="xml">
        <pivot string="Project Tasks">
            <field name="author" type="row"/>
            <field name="state" type="col"/>
        </pivot>
    </field>
</record>
odoo-crm
whatsapp
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