Search code examples
odooodoo-10odoo-view

No results when i try to create custum dashboard in odoo


No results when i try to create custum dashboard in odoo I create a new module for custom dashboard in odoo following this tutorial : link

but always i found the same result is false, here is my code :

The result : enter image description here

** model.py : **

create a dashboard model (kanban.count) and add some filed

class KanbanCount(models.Model)
_name = "kanban.count"

color = fields.Integer(string='Color Index')
name = fields.Char(string="Name")

@api.one
def _get_count(self):
    quotations_count = self.env['sale.order'].search(
        [('sate', '=', 'draft')])
    orders_count = self.env['sale.order'].search(
        [('sate', '=', 'sales_order')])
    orders_done_count = self.env['sale.order'].search(
        [('sate', '=', 'done')])

    self.orders_count = len(orders_count)
    self.quotations_count = len(quotations_count)
    self.orders_done_count = len(orders_done_count)

orders_count = fields.Integer(compute = '_get_count')
quotations_count = fields.Integer(compute= '_get_count')
orders_done_count = fields.Integer(compute= '_get_count')

The Kanban View :

Create a kanban view of this above-created model

  <record model="ir.ui.view" id="count_kanban_form_view">
        <field name="name">Count form</field>
        <field name="model">kanban.count</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">
                        
                        <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.value"/>
                                                </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>
                                            <a  type="action">Quotations</a>
                                        </div>
                                        <div>
                                        <a  type="action">Sales Order</a>
                                        </div>
                                        <div>
                                        <a type="action">Done</a>
                                        </div>
                                        <div>
                                            <a type="action">Cancel</a>
                                        </div>
                                    </div>

                                    <div t-if="widget.editable" class="o_project_kanban_colorpicker" >
                                        <ul class="oe_kanban_colorpicker" data-field="color"/>
                                    </div>
                                </div>

                            </div>

                            <div class="o_project_kanban_boxes" >

                                <a class="o_project_kanban_box" name="" type="action">

                                    <span class="o_value" style="overflow:visible !important">
                                        <span t-esc="record.quotations_count.value"/>
                                    </span>

                                    <span class="o_label" style="overflow:visible !important">
                                        Quotations
                                    </span>

                                </a>
                                    
                                <a class="o_project_kanban_box" name="" type="action">

                                    <span class="o_value" style="overflow:visible !important">
                                        <span t-esc="record.orders_count.value"/>
                                    </span>

                                    <span class="o_label" style="overflow:visible !important">
                                        Sales Orders
                                    </span>
                                </a>
                                
                                <a class="o_project_kanban_box" name="" type="action">
                                    <span class="o_value" style="overflow:visible !important">
                                        <span t-esc="record.order_done_count.value"/>
                                    </span>
                                    <span class="o_label" style="overflow:visible !important">
                                        Done
                                    </span>
                                </a>

                            </div>
                            
                        </div>
                    </span>
                </templates>
            </kanban>
        </field>
    </record>

Solution

  •     <record id="kanabn_count_dashbord" model="kanban.count">
            <field name="name">Kanban Dashboard</field>
        </record>