How to Use Graph View Attributes in Odoo 18: Complete Guide
By Braincuber Team
Published on April 16, 2026
In a world driven by data, swiftly analyzing and understanding complex information is crucial for making informed business decisions. Odoo 18 addresses this need through its powerful Graph View feature, which transforms raw operational data into intuitive, interactive visualizations. This complete tutorial walks you through every aspect of graph view attributes, from basic configuration to advanced customization techniques.
What You'll Learn:
- Step by step guide to understanding graph view structure
- Beginner guide to configuring chart types (bar, line, pie)
- Complete tutorial on essential graph view attributes
- How to implement sample data during development
- Best practices for data visualization in Odoo 18
- Advanced techniques using js_class extensions
- How to optimize graph view performance
Understanding Odoo 18 Graph Views
Graph views in Odoo 18 represent a significant evolution in business intelligence capabilities, building upon previous versions with enhanced customization options and improved user experience. They enable users across departments - from sales managers tracking pipeline growth to manufacturing supervisors monitoring production efficiency - to gain immediate insights through various chart types. This step by step guide covers all aspects of graph view configuration.
These dynamic charts serve as a window into your business performance, revealing patterns, trends, and opportunities that might otherwise remain hidden in spreadsheets or database tables. Understanding how to properly configure graph views is essential for any Odoo developer or business analyst looking to leverage the platform's reporting capabilities.
Bar Charts
Default chart type for comparing values across categories. Ideal for sales reports, inventory counts, and performance metrics.
Line Charts
Perfect for showing trends over time. Best suited for tracking growth patterns, seasonal variations, and historical data analysis.
Pie Charts
Excellent for displaying proportional relationships. Useful for market share analysis, expense breakdowns, and resource allocation.
Stacked Views
For comparative analysis showing part-to-whole relationships. Ideal for multi-category breakdowns within a single metric.
Basic Graph View Structure
Every graph view in Odoo 18 begins with the fundamental
Start with the Graph Tag
Complete tutorial: every graph view begins with the <graph> tag. This tag wraps your field definitions and serves as the container for all chart configuration. The basic structure includes the string attribute for the display title and sample attribute for development data.
Add Field Definitions
Step by step guide: inside the graph tag, you need to define fields using <field> elements. Each field specifies which model attribute to visualize. Configure the type attribute (row, measure, or groupby) to determine how data is aggregated and displayed.
<graph string="Opportunities" sample="1">
<field name="date"/>
<field name="revenue" type="measure"/>
</graph>
Essential Graph View Attributes
Odoo 18 provides a comprehensive set of attributes that control every aspect of graph view behavior and appearance. Understanding each attribute is crucial for creating effective visualizations. This section covers all essential attributes in detail.
| Attribute | Purpose | Values |
|---|---|---|
| string | Display title for the graph view | Text string |
| sample | Enable sample data during development | 0 or 1 |
| type | Chart visualization type | bar, line, pie |
| stacked | Enable stacked bar presentation | 0 or 1 |
| disable_linking | Disable click-through to records | 0 or 1 |
| js_class | Custom JavaScript behavior | Class name |
| class | CSS class for styling | CSS class |
Configuring Chart Types
The type attribute determines the visualization style of your graph view. Understanding when to use each chart type is essential for effective data presentation. This step by step guide explains each option.
Configure Bar Charts
Complete tutorial: bar is the default chart type in Odoo 18 graph views. You can omit the type attribute or explicitly set type="bar". Bar charts are ideal for comparing discrete categories and work best when you have clear categorical distinctions in your data.
Configure Line Charts
Step by step guide: set type="line" to display data as connected points over time. Line charts excel at showing trends and continuous data progression. They are particularly useful for time-series analysis, such as monthly sales trends or quarterly revenue growth.
Configure Pie Charts
Beginner guide: set type="pie" to display data as proportional segments of a circle. Pie charts work best when showing part-to-whole relationships with a limited number of categories. They are ideal for market share analysis, expense breakdowns, and resource allocation visualizations.
<graph string="Workcenter Productivity" type="pie" sample="1">
<field name="workcenter_id" type="row"/>
<field name="duration" type="measure"/>
</graph>
Sample Data Attribute
The sample attribute is particularly useful during development phases when actual data may not yet be available. When set to "1", Odoo displays representative sample data so developers and stakeholders can visualize how the graph will appear with real data.
Pro Tip: Development vs Production
Always remove sample="1" or set it to sample="0" before deploying to production. Sample data should only be visible in development and staging environments.
<graph string="Opportunities" sample="1">
<field name="stage_id" type="row"/>
<field name="planned_revenue" type="measure"/>
</graph>
<!-- Disable sample data for production -->
<graph string="Opportunities" sample="0">
<field name="stage_id" type="row"/>
<field name="planned_revenue" type="measure"/>
</graph>
Stacked and Comparative Views
The stacked attribute controls how multiple data series are displayed within bar charts. This is particularly useful for comparative analysis where you want to see both individual and cumulative values.
Enable Stacked Bars
Complete tutorial: set stacked="1" to display bars as overlapping segments, showing cumulative values. This is useful for understanding total quantities while still seeing individual contributions to the whole.
Use Side-by-Side Bars
Step by step guide: set stacked="0" or omit the attribute entirely to display bars side-by-side. This makes it easier to compare individual values directly without the visual complexity of stacked presentation.
<graph string="Manufacturing Orders" stacked="0" sample="1">
<field name="product_id" type="row"/>
<field name="product_qty" type="measure"/>
</graph>
<!-- Stacked bars -->
<graph string="Manufacturing Orders" stacked="1" sample="1">
<field name="product_id" type="row"/>
<field name="product_qty" type="measure"/>
</graph>
Record Linking Control
The disable_linking attribute controls whether users can click on graph elements to navigate to individual records. This is useful for dashboard views where you want to prevent accidental navigation.
<graph string="Timesheet Attendance" sample="1" disable_linking="1">
<field name="employee_id" type="row"/>
<field name="hours" type="measure"/>
</graph>
<!-- Enable record linking (default) -->
<graph string="Opportunities" sample="1">
<field name="stage_id" type="row"/>
<field name="revenue" type="measure"/>
</graph>
Advanced: Custom JavaScript Extensions
For advanced functionality beyond standard graph capabilities, you can use the js_class attribute to apply custom JavaScript behavior. This enables specialized visualizations and interactive features.
<graph string="Opportunities Forecast" sample="1" js_class="forecast_graph">
<field name="date" type="row"/>
<field name="forecasted_revenue" type="measure"/>
</graph>
<!-- Custom styling with class attribute -->
<graph string="Graph View" class="oe_stock_picking_batch" sample="1">
<field name="location_id" type="row"/>
<field name="quantity" type="measure"/>
</graph>
Practical Implementation Examples
Now that you understand all the attributes, let us examine complete practical examples that you can adapt for your own Odoo 18 implementations. These examples cover common business scenarios.
Sales Opportunity Pipeline
Complete tutorial: create a bar chart showing opportunities by sales stage with revenue as the measure. This visualization helps sales managers quickly assess pipeline health and identify stages requiring attention.
Manufacturing Orders Dashboard
Step by step guide: build a manufacturing dashboard with side-by-side comparison of orders by product. Use stacked="0" for clear product comparisons and sample="1" during development phase.
Workcenter Productivity Analysis
Beginner guide: use pie charts to display workcenter productivity distribution. This helps operations managers understand resource utilization across different workcenters in the manufacturing facility.
<graph string="Opportunities" sample="1">
<field name="stage_id" type="row"/>
<field name="planned_revenue" type="measure"/>
</graph>
<!-- 2. Manufacturing Dashboard -->
<graph string="Manufacturing Orders" stacked="0" sample="1">
<field name="product_id" type="row"/>
<field name="product_qty" type="measure"/>
</graph>
<!-- 3. Resource Productivity -->
<graph string="Workcenter Productivity" type="pie" sample="1">
<field name="workcenter_id" type="row"/>
<field name="duration" type="measure"/>
</graph>
Best Practices for Odoo 18 Graph Views
Following best practices ensures your graph views provide genuine business value and maintain optimal performance. This section summarizes key recommendations for both development and production environments.
Performance Optimization
Use sample="1" during development to test without querying large datasets. Apply domain filters to limit data scope. Keep measures and dimensions minimal for complex datasets to ensure fast rendering.
User Experience
Use clear, descriptive titles with the string attribute. Choose appropriate chart types based on your data characteristics. Maintain consistent styling across related views for intuitive navigation.
Advanced Use Cases
Implement custom JavaScript extensions with js_class for specialized forecasting. Apply CSS styling via the class attribute for consistent theming. Disable linking for dashboard-only views.
Visual Design
Match visualization type to analytical need. Bar charts for comparisons, line charts for trends, pie charts for proportions. Test visualizations with actual data before deployment.
Frequently Asked Questions
What are the available chart types in Odoo 18 graph views?
Odoo 18 graph views support three main chart types: bar (default), line, and pie. Set the type attribute to "bar", "line", or "pie" respectively. Bar charts are ideal for comparisons, line charts for trends, and pie charts for proportional relationships.
How do I enable sample data in Odoo 18 graph views?
Add sample="1" to your graph tag to enable sample data display during development. This shows representative data even when no actual records exist. Remember to set sample="0" or remove the attribute before deploying to production.
What is the difference between stacked and side-by-side bars?
Stacked bars (stacked="1") show cumulative values with segments overlapping. Side-by-side bars (stacked="0") display segments next to each other for direct comparison. Use stacked for part-to-whole analysis and side-by-side for direct value comparisons.
How do I disable record linking in graph views?
Add disable_linking="1" to the graph tag to prevent users from clicking graph elements to navigate to individual records. This is useful for dashboard views where you want to prevent accidental navigation. Omit the attribute or set it to "0" to enable linking.
When should I use the js_class attribute in graph views?
Use js_class when you need custom JavaScript behavior beyond standard graph functionality, such as specialized forecasting features or custom interactive elements. It requires corresponding JavaScript code to be registered in Odoo's web assets. For standard visualizations, the default behavior is sufficient.
Need Help with Odoo 18 Graph Views?
Our Odoo experts can help you implement powerful data visualizations and business intelligence dashboards. From graph view configuration to custom JavaScript extensions, we help businesses transform raw data into actionable insights.
