Dashboards In Odoo 18 deliver an organized visual presentation of essential business data. Users can track essential metrics through dashboards to monitor performance and make efficient decisions. Odoo 18 provides users with improved dashboard creation capabilities because of its enhanced tools and better user interface. The powerful flexible ERP system Odoo enables multiple methods to present and handle data. The views system in Odoo 18 determines how users interact with records throughout different modules. The views system improves user experience through organized layouts that present information in an attractive manner.
This blog provides a complete guide to building custom dashboards in Odoo 18 starting from fundamental setup through advanced customization. This guide serves both developers and business users to create customized dashboards that fulfill their particular requirements. Let’s get started!
In Odoo 18 client actions function as the mechanism to display dashboards. Users can access interactive and dynamic dashboard views through menu items which trigger these actions.
Defining the Client Action
To render a custom dashboard, we need to define a client action in the ir.actions.client model. This action links the dashboard to a specific JavaScript component via a tag.
CRM Dashboard
crm_dashboard_tag
* ‘name’ field: Defines the display name of the dashboard in Odoo.
* ‘tag’ field: Links the JavaScript file with the client action.
When the “Dashboard” menu item is clicked, it triggers crm_dashboard_action, which then connects to the JavaScript file via the specified tag (crm_dashboard_tag).
Creating the JavaScript Component
Next, we create a JavaScript component that will handle the rendering of the dashboard. Create a JavaScript file in static/src/js/dashboard.js:
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { Component } from "@odoo/owl";
const actionRegistry = registry.category("actions");
class CrmDashboard extends Component {}
CrmDashboard.template = "my_module.CrmDashboard";
// Register the component with the action tag
actionRegistry.add("crm_dashboard_tag", CrmDashboard);
* The JavaScript file imports Odoo’s Owl framework to define a dashboard component.
* The actionRegistry.add() method connects the component to the crm_dashboard_tag, ensuring it is triggered when the action is called.
* The component uses an XML template to define the dashboard’s UI.
At this stage, the user interface will display a blank dashboard view.
Creating the Dashboard Template
To display content inside the dashboard, we need to create an XML template. Create an XML file in static/src/xml/dashboard.xml:
CRM Dashboard
* The template defines a simple heading (“CRM Dashboard”) centered on the page.
* This template is linked to the JavaScript component through the t-name=”my_module.CrmDashboard” attribute.
Adding Files to the Manifest
To ensure the JavaScript and XML files are loaded correctly, they must be included in the module’s __manifest__.py file:
'assets': {
'web.assets_backend': [
'my_module/static/src/js/dashboard.js',
'my_module/static/src/xml/dashboard.xml',
],
},
This ensures that the dashboard assets are properly loaded in the Odoo backend.
After completing these steps, you will have a functional blank dashboard integrated into Odoo 18. You can now expand it by adding widgets, charts, and other interactive components to enhance usability.
Adding Tiles to the Odoo Dashboard
Now let’s add tiles to the Odoo dashboard and fetch data dynamically using ORM calls in JavaScript.
HTML Structure for Tiles:
My Leads
My Opportunity
Expected
revenue
Fetching Data using JavaScript ORM Call:
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
const actionRegistry = registry.category("actions");
class CrmDashboard extends Component {
setup() {
super.setup();
this.orm = useService('orm');
this._fetch_data();
}
async _fetch_data(){
let result = await this.orm.call("crm.lead", "get_tiles_data", [], {});
document.getElementById('my_lead').innerHTML = `${result.total_leads}`;
document.getElementById('my_opportunity').innerHTML = `${result.total_opportunity}`;
document.getElementById('revenue').innerHTML = `${result.currency}${result.expected_revenue}`;
}
}
CrmDashboard.template = "my_module.CrmDashboard";
actionRegistry.add("crm_dashboard_tag", CrmDashboard);
Fetching Data from the Model (crm.lead):
from odoo import models, api
class CrmLead(models.Model):
_inherit = 'crm.lead'
@api.model
def get_tiles_data(self):
company_id = self.env.company
leads = self.search([('company_id', '=', company_id.id),
('user_id', '=', self.env.user.id)])
my_leads = leads.filtered(lambda r: r.type == 'lead')
my_opportunity = leads.filtered(lambda r: r.type == 'opportunity')
currency = company_id.currency_id.symbol
expected_revenue = sum(my_opportunity.mapped('expected_revenue'))
return {
'total_leads': len(my_leads),
'total_opportunity': len(my_opportunity),
'expected_revenue': expected_revenue,
'currency': currency,
}
As you can see, the get_tiles_data() function retrieves data from the crm.lead model, fetching the total number of leads, opportunities, and expected revenue for the logged-in user within their company.
The final dashboard output will display tiles summarizing key CRM metrics, including the total number of leads, opportunities, and expected revenue.
This is a simple dashboard that provides key CRM insights using dynamic tiles. You can further enhance it with additional graphical elements, charts, or other customizations based on your specific needs.
Empower Your Business with Custom Dashboards in odoo 18
Odoo 18 allows businesses to create personalized dashboards which display essential real-time metrics and KPIs and actionable insights that match their specific needs. Users can build dashboards that combine visual appeal with functionality through client actions and JavaScript components and dynamic ORM-based data fetching. The dashboards serve as a single platform which enables performance tracking and better decision-making and increased productivity across different departments. The improved dashboards in Odoo 18 provide developers and business users with the necessary flexibility to achieve business success through custom view implementation and data visualization. Begin your journey to create a custom dashboard which transforms raw data into strategic advantage.



