top of page

Odoo Dashboard in Odoo 18: Chart Types, Use Cases and How to Build One

Writer: Bernard Bryan Hayashi
Bernard Bryan Hayashi
1 day ago
5 min read

Every business wants the same thing from its system: the important numbers on one screen, always up to date, without exporting data to Excel. In Odoo 18, that is exactly what the Dashboards app is for.


At Excelroot we build custom Odoo dashboards for our clients, from sales and finance overviews to a membership dashboard for a professional institute in Malaysia. In this article we explain what an Odoo dashboard is, which chart types you can use and when, how to create one, and finally how to build one in code with Odoo 18.


What is an Odoo Dashboard?

An Odoo dashboard is a read-only page in the Dashboards app that shows KPIs and charts built on your live Odoo data. Behind the scenes, each dashboard is an Odoo spreadsheet displayed in view mode.

  • Live data: figures are read from Odoo every time the dashboard is opened, so there is nothing to refresh or re-import.

  • Global filters: one filter at the top, such as a period or a salesperson, applies to every chart on the page.

  • Click-through: click a chart and Odoo opens the matching list of records.

  • Access control: each dashboard is visible only to the user groups you choose.


Chart types available in Odoo 18

Odoo 18 dashboards support two families of charts:

  • Odoo charts (bar, line and pie) read records straight from an Odoo model and group them by a field, for example revenue by customer.

  • Spreadsheet charts read values from cells. Those cells are usually filled with Odoo formulas such as PIVOT.VALUE, so they are live as well.


Here are the chart types you can use, and what each one is good for.


Scorecard (KPI card)

A single number with a short comparison line underneath. Use it for headline figures such as total revenue, number of orders or active members.


Bar chart

Compares values across categories, such as revenue by customer or members by state. Bars can be vertical or horizontal, and stacked.


Line chart

Shows a trend over time, such as revenue by month. It can fill the area under the line or show cumulative values.

Scorecards, an Odoo bar chart and a line chart (demo data)
Scorecards, an Odoo bar chart and a line chart (demo data)

Pie chart

Shows the share of each part in a whole, such as quotations versus confirmed orders. Works best with a small number of categories.


Gauge

Shows progress toward a target, with red, amber and green zones that you define. Typical uses are sales target achievement, budget usage or service level.


A pie chart and a gauge (demo data)
A pie chart and a gauge (demo data)

Combo chart

Combines bars and a line with two separate axes, so you can show two measures with different scales together, such as revenue and number of orders per month.


Waterfall chart

Explains how a starting value turns into a final value step by step, such as a profit bridge from revenue to net profit.


A combo chart and a waterfall chart (demo data)
A combo chart and a waterfall chart (demo data)

Pyramid chart

Puts two groups back to back, such as female and male customers by age group, so their distributions are easy to compare.


Scatter chart

Plots one number against another to reveal a relationship, such as discount percentage against order size.


A pyramid chart and a scatter chart (demo data)
A pyramid chart and a scatter chart (demo data)


Technical guide: building an Odoo 18 dashboard in code

A dashboard in code is a small Odoo module with three parts: the manifest, an XML record, and a JSON file that contains the spreadsheet.

my_dashboard/
├── __manifest__.py
└── data/
    ├── dashboards.xml
    └── files/
        └── sales_overview.json

Step 1: the manifest

The module only needs to depend on spreadsheet_dashboard and on the app whose data you want to show.

{
    "name": "Sales Overview Dashboard",
    "version": "18.0.1.0.0",
    "depends": ["spreadsheet_dashboard", "sale"],
    "data": ["data/dashboards.xml"],
    "license": "LGPL-3",
}

Step 2: register the dashboard

A spreadsheet.dashboard.group is a section in the Dashboards sidebar. The spreadsheet.dashboard record loads the JSON file and decides who can see it.

<record id="dashboard_group_overview" model="spreadsheet.dashboard.group">
    <field name="name">Overview</field>
    <field name="sequence">10</field>
</record>

<record id="dashboard_sales_overview" model="spreadsheet.dashboard">
    <field name="name">Sales Overview</field>
    <field name="spreadsheet_binary_data" type="base64"
           file="my_dashboard/data/files/sales_overview.json"/>
    <field name="main_data_model_ids" eval="[(4, ref('sale.model_sale_order'))]"/>
    <field name="dashboard_group_id" ref="dashboard_group_overview"/>
    <field name="group_ids" eval="[Command.link(ref('base.group_user'))]"/>
    <field name="is_published">True</field>
</record>

Step 3: a data source and a global filter

The JSON file uses the Odoo spreadsheet format. A pivot of type ODOO reads a model with a domain and a measure. A global filter is shown above the dashboard, and fieldMatching tells it which field to filter on in each data source.

"globalFilters": [{
    "id": "f-year", "type": "date", "label": "Year",
    "rangeType": "fixedPeriod", "defaultValue": "this_year"
}],
"pivots": {
    "1": {
        "type": "ODOO", "id": "1", "formulaId": "1", "name": "Revenue",
        "model": "sale.order",
        "domain": [["state", "=", "sale"]],
        "measures": [{"id": "amount_untaxed", "fieldName": "amount_untaxed"}],
        "rows": [], "columns": [],
        "fieldMatching": {
            "f-year": {"chain": "date_order", "type": "datetime", "offset": 0}
        }
    }
}

Step 4: a KPI card

Put the value in a cell with an Odoo formula, for example =PIVOT.VALUE(1,"amount_untaxed") in cell Data!B2, then point a scorecard figure at that cell.

{
    "id": "card-revenue", "tag": "chart",
    "x": 0, "y": 10, "width": 315, "height": 110,
    "data": {
        "type": "scorecard",
        "title": {"text": "Total Revenue"},
        "keyValue": "Data!B2",
        "baseline": "Data!C2",
        "baselineMode": "text"
    }
}

Step 5: a live Odoo chart

Odoo charts (odoo_bar, odoo_line, odoo_pie) read and group records themselves, so they need no cells. Give each chart its own fieldMatching so it follows the global filter.

{
    "id": "chart-customers", "tag": "chart",
    "x": 0, "y": 140, "width": 485, "height": 300,
    "data": {
        "type": "odoo_bar",
        "title": {"text": "Revenue by Customer"},
        "metaData": {
            "resModel": "sale.order", "groupBy": ["partner_id"],
            "measure": "amount_untaxed", "order": "DESC", "mode": "bar"
        },
        "searchParams": {
            "domain": [["state", "=", "sale"]], "groupBy": ["partner_id"],
            "orderBy": [], "context": {}, "comparison": null
        },
        "fieldMatching": {
            "f-year": {"chain": "date_order", "type": "datetime", "offset": 0}
        }
    }
}

Step 6: click-through to records

A figure can be linked to an Odoo menu. Clicking the card or chart then opens that menu's list view.

"chartOdooMenusReferences": {
    "chart-customers": "sale.menu_sale_order"
}

Step 7: install the module

Install or upgrade the module. The dashboard is reloaded from the JSON file every time.

./odoo-bin -c odoo.conf -d my_database -u my_dashboard

Going further


Custom business rules with a search-only field

A global filter can only put a date range on one field. When a KPI needs a business rule, such as customers whose contract was active during the selected year, add a non-stored field with a search method that translates the date range into your rule. The example below assumes two existing fields, contract_start and contract_end.

from odoo import fields, models


class ResPartner(models.Model):
    _inherit = "res.partner"

    # Not stored: only used to filter dashboards
    active_period = fields.Date(
        compute="_compute_active_period",
        search="_search_active_period",
    )

    def _compute_active_period(self):
        for partner in self:
            partner.active_period = partner.contract_start

    def _search_active_period(self, operator, value):
        # The filter sends: field >= period start AND field <= period end
        if operator in (">=", ">"):
            return ["|", ("contract_end", "=", False),
                    ("contract_end", operator, value)]
        return [("contract_start", operator, value)]

Then point the filter at the new field: "chain": "active_period". The same rule also works in normal list views and search filters.


Drill down and drill up

A dashboard can hold several sheets. A cell link to another sheet works as a drill down, and a link back works as a drill up, with no JavaScript needed.

[Drill down ▾](o-spreadsheet://detail-sheet)
[▴ Back to dashboard](o-spreadsheet://sheet1)

Practical tips

  • Validate the JSON before upgrading, for example with python -m json.tool. A broken file shows an empty dashboard.

  • Every figure needs a unique id, and every data source that should follow a filter needs its own fieldMatching.

  • One global filter maps to one field per data source. Use two data sources if you need two different date rules.

  • To hide standard dashboards you do not use, set is_published to False instead of deleting them.


Need a custom Odoo dashboard?

Excelroot designs and builds custom Odoo dashboards for sales, finance, inventory, membership and more, on both Odoo Community and Enterprise. Contact our team for a demo or to discuss the KPIs your business needs.

Screenshots in this article use Odoo demo data.

 
 
 

Recent Posts

See All
Integrating EasyParcel with Odoo

Connect Odoo to EasyParcel to fetch live courier rates and create shipments from the website checkout and from sales orders. Benefits Live rates from several couriers (Aramex, J&T, DHL eCommerce, Laza

 
 
 

Comments


Subscribe Form

  • facebook
  • linkedin

©2019 by Excelroot Technology Sdn Bhd.

bottom of page