Create Custom Dashboard in Odoo12
Dashboards in Odoo are useful for visualization of data in a better way. In this article, I am going to explain how to create a custom Dashboard in Odoo12. For creating the dashboard follow the steps below.
Step 1 :-> For creating a dashboard you need to create a model (custom.sales.dashboard in my case) and add some filed in it like color, name etc based on your requirement.
class CustomSalesDashboard(models.Model):
_name = "custom.sales.dashboard"
color = fields.Integer(string='Color Index')
name = fields.Char(string="Name")
Step 2:-> Create a kanban and form or tree view of this above-created model. You can create a kanban view and customize it as per your requirement. I have created a basic kanban view of the above model.
<record id="channel_dashboard_form_view" model="ir.ui.view"> <field name="name">custom.sales.dashboard.form.view</field> <field name="model">custom.sales.dashboard</field> <field name="arch" type="xml"> <form> <field name="color"/> <field name="name"/> </form> </field> </record>
<record id="channel_dashboard_form_view_tree" model="ir.ui.view"> <field name="name">custom.sales.dashboard.tree.view</field> <field name="model">custom.sales.dashboard</field> <field name="arch" type="xml"> <tree> <field name="color"/> <field name="name"/> </tree> </field> </record>
<record id="channel_dashboard_kanban_view" model="ir.ui.view">
<field name="name">custom.sales.dashboard.view</field>
<field name="model">custom.sales.dashboard</field>
<field name="arch" type="xml">
<kanban class="oe_background_grey o_kanban_dashboard o_salesteam_kanban o_project_kanban " create="0">
<field name="color"/>
<field name="name"/>
<templates>
<span t-name="kanban-box"> <!-- User t tag(<t>) instead of <span> in Odoo for color change-->
<div t-attf-class="#{kanban_color(record.color.raw_value)} oe_kanban_global_click_edit " style="padding-left:10px; height:300px" >
<div class="o_project_kanban_manage">
<a class="o_kanban_manage_toggle_button" href="#" style="margin-top:10px">More <i class="fa fa-caret-down"/></a>
</div>
<div class="o_project_kanban_main wk_o_project_kanban_main">
<div class="o_kanban_card_content o_visible oe_kanban_global_click" style="display:block">
<div class="o_kanban_primary_left">
<div class="o_primary">
<center>
<span style="font-size:22px;"> This is a Test Dashboard</span>
<span style="color:black;">
<span t-field="record.name.value"/>
</span>
</center>
</div>
</div>
</div>
<div class="container o_kanban_card_manage_pane dropdown-menu" role="menu">
<div class="row o_kanban_card_settings" >
<div t-if="widget.editable" class="o_project_kanban_colorpicker">
<ul class="oe_kanban_colorpicker" data-field="color"/>
</div>
</div>
</div>
</div>
</div>
</span>
</templates>
</kanban>
</field>
</record>
Step 3 :-> Create the action of the above view.
<record id="custom_sales_dashboard_action" model="ir.actions.act_window"> <field name="name">Dashboard</field> <field name="type">ir.actions.act_window</field> <field name="res_model">custom.sales.dashboard</field> <field name="view_mode">kanban,tree,form</field> <field name="view_type">form</field> <field name="view_id" ref="channel_dashboard_form_view_tree"/> </record>
Step 4:-> Create the Menu for this action.
<menuitem id="dashboard_test" name="Dashboard Test" parent="sale.sale_order_menu" action="test_dashboard.custom_sales_dashboard_action"/>
This is all for creating a basic dashboard, now your dashboard is ready to use.
For odoo10 Visit this link : https://webkul.com/blog/creating-odoo-custom-dashboard/
That is it.!!!
If you liked this post, It would be very grateful if you write your opinions, comments and suggestions to keep the post updated and interesting.
Thank you!