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

时间:2019-01-15 09:34:51

标签: odoo odoo-10 odoo-view

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

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

结果: enter image description here

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:-1)

使用“ t”标签删除“ span”标签。

例如:

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

只需将上述行替换为(也要关闭标签):

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

尝试,我希望它会成功

谢谢