当我尝试在 odoo 中创建自定义仪表板时没有结果

No results when i try to create custum dashboard in odoo

当我尝试在 odoo 中创建自定义仪表板时没有结果 我按照本教程在 odoo 中为自定义仪表板创建了一个新模块:link

但我总是发现相同的结果是错误的,这是我的代码:

结果:

** model.py : **

创建仪表板模型 (kanban.count) 并添加一些字段

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')

看板视图:

为上面创建的模型创建看板视图

  <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>

删除带有 "t" 标签的 "span" 标签。

例如:

<span t-name="kanban-box">

只需将上面一行替换为(结束标记也一样):

<t t-name="kanban-box">

尝试一下,我希望它会成功

谢谢

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