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.
This is the graph view type in the form of line chart.
This is the graph view type in the form of pie chart.
Graph view can use the following attributes:
Type:
Bar, pie and line. Default type is bar.