Chapter 6 - Odoo 15 Development Book

Graph view

Odoo supports several views such as tree view, form view, list view, Kanban view, pivot view, calendar view etc. Graph views provide a graphical view of the data, in the form of Bar chart, Pie chart, and Line chart. Its root element is <graph>

Let’s create a graph 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 a 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,graph</field>
</record>

This is the graph view of this model

<record model="ir.ui.view" id="view_book">
   	<field name="name">book.graph</field>
   	<field name="model">book</field>
   	<field name="type">graph</field>
   	<field name="arch" type="xml">
       		<graph string="Book" type="bar">
           		<field name="state" group="True"/>
           		<field name="author" operator="*"/>
       		</graph>
   	</field>
</record>

This is the graph view type in the form of bar chart.

odoo-crm

This is the graph view type in the form of line chart.

odoo-crm

This is the graph view type in the form of pie chart.

odoo-crm

Graph view can use the following attributes:

Type:

Bar, pie and line. Default type is bar.

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