Creating Odoo Custom Dashboard
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 Odoo. 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 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_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"> <!-- Use <t> tag instead of <span> for color change --> <div t-attf-class="#{kanban_color(record.color.raw_value)} "> <div class="o_project_kanban_manage"> <a class="o_kanban_manage_toggle_button" href="#">More <i class="fa fa-caret-down"/> </a> </div> <div class="o_project_kanban_main" > <div class="o_kanban_card_content o_visible"> <div class="o_kanban_primary_left" > <div class=""> <center> <span> <span t-field="record.name"/> </span> </center> </div> <div> <center> <button class="btn btn-primary" type="action" name="dashboard_sales_action_id" string="Quotations">Quotations</button> <button class="btn btn-primary" type="action" name="dashboard_sales_order_action_id" >Sales order</button> <h3>Custom Dashboard for Sales</h3> </center> </div> </div> </div> <div class="o_kanban_card_manage_pane o_invisible"> <div class="col-xs-6 o_kanban_card_manage_section o_kanban_manage_view"> <div class="o_kanban_card_manage_title"> <span>View</span> </div> </div> <div t-if="widget.editable" class="o_project_kanban_colorpicker" > <ul class="oe_kanban_colorpicker" data-field="color"/> </div> </div> </div> </div> </span> </templates> </kanban> </field> </record>
<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>
- 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="res_model">custom.sales.dashboard</field> <field name="type">ir.actions.act_window</field> <field name="view_type">form</field> <field name="context">{}</field> <field name="view_mode">kanban,form</field> </record>
- Step 4:-> Create the Menu for this action.
<menuitem id="menu_sales_config_inherited" parent= "sales_team.menu_sale_config" sequence= "1" name= "Sales Test dashboard" action="custom_sales_dashboard_action"/>
- This is all for creating a basic dashboard, now your dashboard is ready to use.
This blog has been updated and I hope all of you there who faced any kind of issue you can try it again now. I have created the form view also that you can create a record also for the test purpose.
For odoo12 dashboard Visit this link: https://webkul.com/blog/custom-dashboard-odoo12/
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!