Graph View Attributes in Odoo 18: Complete Reference
By Braincuber Team
Published on January 19, 2026
Raw data becomes useful when you can see patterns. Odoo 18's Graph View transforms your business data into bar charts, line graphs, and pie charts—visualizations that reveal trends, comparisons, and distributions at a glance. Whether you're tracking sales pipeline stages, monitoring inventory levels, or analyzing employee performance, graph views turn numbers into insights.
This tutorial documents all the graph view attributes available in Odoo 18, with practical examples for each. You'll learn how to configure chart types, control data presentation, apply custom styling, and create production-ready visualizations for your modules.
Where Graph Views Appear: Graph views can be defined for any model and accessed via the view switcher in tree views, or embedded in dashboards and reporting menus.
Available Chart Types
Bar Chart
Default type. Compare quantities across categories.
Line Chart
Show trends over time. Good for time series data.
Pie Chart
Show proportions. Best for part-to-whole relationships.
Core Attributes Reference
| Attribute | Values | Purpose |
|---|---|---|
| string | "Title" | Display title for the graph view |
| type | bar, line, pie | Chart visualization type (default: bar) |
| stacked | "0" or "1" | Stack bars (1) or show side-by-side (0) |
| sample | "0" or "1" | Show sample data when no records exist |
| disable_linking | "0" or "1" | Prevent clicking through to records |
| js_class | custom_class | Apply custom JavaScript behavior |
| class | CSS class | Apply custom CSS styling |
Basic Graph View Structure
Every graph view starts with the <graph> tag and includes <field> elements for dimensions and measures:
<graph string="Sales Analysis" sample="1">
<!-- Dimension (X-axis grouping) -->
<field name="partner_id" type="row"/>
<!-- Measure (Y-axis values) -->
<field name="amount_total" type="measure"/>
</graph>
Chart Type Examples
Bar Chart (Default)
<graph string="Sales by Salesperson" sample="1">
<field name="user_id" type="row"/>
<field name="amount_total" type="measure"/>
</graph>
Line Chart
<graph string="Monthly Revenue" type="line" sample="1">
<field name="date_order" interval="month" type="row"/>
<field name="amount_total" type="measure"/>
</graph>
Pie Chart
<graph string="Leads by Stage" type="pie" sample="1">
<field name="stage_id" type="row"/>
<field name="expected_revenue" type="measure"/>
</graph>
Advanced Attributes
Stacked vs Side-by-Side Bars
<!-- Stacked: bars overlap showing cumulative totals -->
<graph string="Orders by Product Category" stacked="1" sample="1">
<field name="categ_id" type="row"/>
<field name="product_uom_qty" type="measure"/>
</graph>
<!-- Side-by-side: bars appear next to each other -->
<graph string="Orders by Product Category" stacked="0" sample="1">
<field name="categ_id" type="row"/>
<field name="product_uom_qty" type="measure"/>
</graph>
Disable Record Linking
<!-- Clicking chart elements won't open records -->
<graph string="KPI Dashboard" disable_linking="1" sample="1">
<field name="state" type="row"/>
<field name="count" type="measure"/>
</graph>
Use Case: Use disable_linking="1" for embedded dashboard graphs where you don't want users to navigate away.
Custom JavaScript Extensions
<!-- Apply custom JavaScript behavior -->
<graph string="Revenue Forecast" js_class="forecast_graph" sample="1">
<field name="date_order" interval="month" type="row"/>
<field name="amount_total" type="measure"/>
</graph>
Note: The js_class attribute requires a corresponding JavaScript class registered in your module's static assets. This enables specialized behaviors like forecasting, custom tooltips, or interactive filters.
Complete Example
<record id="view_sale_order_graph" model="ir.ui.view">
<field name="name">sale.order.graph</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<graph string="Sales Analysis" type="bar" stacked="0" sample="1">
<!-- Group by date (monthly) -->
<field name="date_order" interval="month" type="row"/>
<!-- Secondary grouping by salesperson -->
<field name="user_id" type="col"/>
<!-- Measure: total revenue -->
<field name="amount_total" type="measure"/>
</graph>
</field>
</record>
Best Practices
Graph View Guidelines:
- Use
sample="1"during development: Shows placeholder data when no records exist. - Choose the right chart type: Bar for comparisons, line for trends, pie for proportions.
- Limit dimensions and measures: Too many fields make graphs unreadable.
- Use
disable_linkingfor dashboards: Prevents accidental navigation. - Apply domain filters: Pre-filter data for focused analysis.
Conclusion
Graph views in Odoo 18 provide flexible, declarative data visualization. With attributes like type, stacked, sample, disable_linking, and js_class, you can create everything from simple bar charts to custom forecast dashboards. The key is matching the visualization to your data: bar charts for comparisons, line charts for trends over time, and pie charts for proportional breakdowns.
Key Takeaway: Start with <graph string="Title" type="bar/line/pie" sample="1">. Add <field type="row"> for dimensions and <field type="measure"> for values. Use stacked, disable_linking, and js_class for advanced control.
