Hello Odooers & Developers,
Welcome to Our Odoo technical blog! In this odoo technical article, we will explore how to create a Graph View in Odoo to visualize data more meaningfully. Graph Views help present data as bar charts, line graphs, or pie charts, making it easier to analyze trends, generate reports, and make informed business decisions.
In this article, you'll learn:
- What the Graph View is, and when to use it
- How to configure a Graph View in XML
- A practical example of implementing a Graph View in Odoo
What is a Graph View in Odoo?
A Graph View in Odoo is a unique view that helps display data in bar charts, line graphs, or pie charts. It is built using the Odoo graph tag, making visualizing records easier than viewing raw data in list or form views.
Odoo supports three types of graphs:
- Bar Chart – Best for comparing categories or groups
- Line Chart – Ideal for showing trends over time
- Pie Chart – Used to display proportions or percentages
Step-by-Step Implementation
1. Define the graph View in XML
Now, let's create a Graph View for this model.
Graph View XML Definition:
.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_custom_model_graph" model="ir.ui.view">
<field name="name">custom.model.graph</field>
<field name="model">custom.model</field>
<field name="arch" type="xml">
<graph string="Custom Model Graph">
<field name="date" type="row"/>
<field name="value" type="measure"/>
</graph>
</field>
</record>
<record id="action_custom_model_graph" model="ir.actions.act_window">
<field name="name">Custom Model Graph</field>
<field name="res_model">custom.model</field>
<field name="view_mode">graph</field>
</record>
</odoo>
How Does This Work?
- <graph string="Custom Model Graph"> Defines the graph’s title.
- <field name="date" type="row"/> Groups data by the date field.
- <field name="value" type="measure"/> Uses value as the numeric measure for the graph.
2. Add the View to an Action
To display the Graph View, we need to create an action in XML.
.py
<record id="action_custom_model_graph" model="ir.actions.act_window">
<field name="name">Custom Model Graph</field>
<field name="res_model">custom.model</field>
<field name="view_mode">graph</field>
</record>
Example Use Case
Imagine you are managing an employee attendance system and want to track monthly attendance records. Using the Graph View, you can visualize each month's total number of present, absent, or late entries. This helps HR teams quickly analyze attendance patterns and take necessary actions.
Conclusion
The Graph View in Odoo is a powerful tool for visualizing data in a clear and meaningful way. Whether you need bar charts, line graphs, or pie charts, adding a Graph View to your Odoo module improves data analysis and reporting.
If you want odoo technical training on any odoo version , please let us know by mail at [email protected]. Then next, our odoo expoert will conduct online or offline training with you
Devintellecs & team are odoo training providers in the USA and INDIA, so we will try our best to give the training either individal or any bulk employee company.
If you want to check your odoo technical or functional knowledge, then we have prepared the odoo EXam practice test for the odoo technical & functional people.