扩展Odoo中的视图不起作用

时间:2017-03-09 19:02:17

标签: openerp

我无法弄清楚为什么我无法在Odoo中成功扩展此视图。我试图在销售信息中心的看板卡中的某个按钮上添加一些内容。

基本视图为crm.team.dashboard,具有以下架构:

<?xml version="1.0"?>
<kanban class="oe_background_grey o_kanban_dashboard o_salesteam_kanban" create="0" js_class="sales_team_dashboard">
                <field name="name"/>
                <field name="user_id"/>
                <field name="member_ids"/>
                <field name="color"/>
                <templates>
                    <t t-name="kanban-box">
                        <div t-attf-class="#{kanban_color(record.color.raw_value)}">
                            <div class="o_kanban_card_header">
                                <div class="o_kanban_card_header_title">
                                    <div class="o_primary"><field name="name"/></div>
                                </div>
                                <div class="o_kanban_manage_button_section">
                                    <a class="o_kanban_manage_toggle_button" href="#">More <i class="fa fa-caret-down"/></a>
                                </div>
                            </div>
                            <div class="container o_kanban_card_content o_visible">
                                <div class="row">
                                    <div class="col-xs-6 o_kanban_primary_left" name="to_replace_in_sale_crm">
                                    </div>
                                    <div class="col-xs-6 o_kanban_primary_right">
                                    </div>
                                </div>
                            </div><div class="container o_kanban_card_manage_pane o_invisible">
                                <div class="row">
                                    <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_view">
                                        <div class="o_kanban_card_manage_title">
                                            <span>View</span>
                                        </div>
                                    </div>
                                    <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_new">
                                        <div class="o_kanban_card_manage_title">
                                            <span>New</span>
                                        </div>
                                    </div>
                                    <div class="col-xs-4 o_kanban_card_manage_section o_kanban_manage_reports">
                                        <div class="o_kanban_card_manage_title">
                                            <span>Reports</span>
                                        </div>
                                    </div>
                                </div>

                                <div t-if="widget.editable" class="o_kanban_card_manage_settings row" groups="sales_team.group_sale_manager">
                                    <div class="col-xs-8">
                                        <ul class="oe_kanban_colorpicker" data-field="color"/>
                                    </div>
                                    <div class="col-xs-4 text-right">
                                        <a type="edit">Settings</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </t>
                </templates>
            </kanban>

有一个视图扩展了这个,增加了原始的#34;语录&#34;按钮到看板卡。它是crm.team.kanban视图,它具有以下架构:

<?xml version="1.0"?>
<data>
            <xpath expr="//templates" position="before">
                <field name="use_quotations"/>
                <field name="use_invoices"/>
                <field name="invoiced"/>
                <field name="invoiced_target"/>
                <field name="currency_id"/>
            </xpath>

            <xpath expr="//div[contains(@class, 'o_kanban_primary_right')]" position="inside">
                <div class="row mb4" t-if="record.use_invoices.raw_value">
                    <div class="col-xs-8">
                        <a name="266" type="action">
                            Sales to Invoice
                        </a>
                    </div>
                    <div class="col-xs-4 text-right">
                        <field name="sales_to_invoice_amount" widget="monetary"/>
                    </div>
                </div>
            </xpath>

            <xpath expr="//div[contains(@class, 'o_kanban_primary_left')]" position="inside">
                <button class="btn btn-primary" name="267" type="action">Quotations</button>
            </xpath>

            <xpath expr="//div[contains(@class, 'o_kanban_primary_right')]" position="after">
                <div t-if="record.invoiced_target.raw_value" class="col-xs-12 o_kanban_primary_bottom" groups="sales_team.group_sale_manager">
                    <field name="invoiced" widget="progress" title="Invoicing" options="{'current_value': 'invoiced', 'max_value': 'invoiced_target', 'editable': true, 'edit_max_value': true, 'on_change': 'update_invoiced_target'}"/>
                </div>
                <div t-if="!record.invoiced_target.raw_value" class="col-xs-12 o_kanban_primary_bottom text-center" groups="sales_team.group_sale_manager">
                    <a href="#" class="sales_team_target_definition o_inline_link">Click to define a team target</a> 
                </div>
            </xpath>

            <xpath expr="//div[contains(@class, 'o_kanban_manage_view')]" position="inside">
                <t t-if="record.use_quotations.raw_value">
                    <div>
                        <a name="267" type="action" class="o_quotation_view_button">Quotations</a>
                    </div>
                    <div>
                        <a name="265" type="action">Sales Orders</a>
                    </div>
                </t>
                <div t-if="record.use_invoices.raw_value" groups="account.group_account_invoice">
                    <a name="268" type="action">Invoices</a>
                </div>
            </xpath>

            <xpath expr="//div[contains(@class, 'o_kanban_manage_new')]" position="inside">
                <div t-if="record.use_quotations.raw_value">
                    <a name="272" type="action">
                        Quotation
                    </a>
                </div>
            </xpath>

            <xpath expr="//div[contains(@class, 'o_kanban_manage_reports')]" position="inside">
                <t t-if="record.use_quotations.raw_value">
                    <div>
                        <a name="269" type="action">
                            Quotation
                        </a>
                    </div>
                    <div>
                        <a name="270" type="action">
                            Sales
                        </a>
                    </div>
                </t>
                <div t-if="record.use_invoices.raw_value" groups="account.group_account_invoice">
                    <a name="271" type="action">
                        Invoices
                    </a>
                </div>
            </xpath>

        </data>

我的目标是在&#34; Quotations&#34;中添加一些额外的文字。按钮,所以它说&#34; Quotations(10)&#34;。我创建了一个名为x_crm.team.dashboard的新视图,它继承自crm.team.dashboard,并为其提供了以下架构:

<?xml version="1.0"?>
<data>
    <xpath expr="//div[contains(@class, 'o_kanban_primary_left')]/button" position="inside">
        Quotations (Test)
    </xpath>
</data>

但是,当我查看仪表板时,我的更改未显示。我只看到原版&#34;报价&#34;按钮。我在过去有过扩展的观点并且工作正常,但在这种情况下我似乎遗漏了一些东西。

有没有人知道我做错了什么?

2 个答案:

答案 0 :(得分:0)

试试这个

扩展ID为crm.team.kanban

的视图
<xpath expr="//button[@name='267']" position="replace">
    <button class="btn btn-primary" name="267" type="action">Quotations (Test)</button>
</xpath>

答案 1 :(得分:0)

这最终为我工作。扩展crm.team.dashboard

<xpath expr="//div[contains(@class, 'o_kanban_primary_left')]/button" position="replace">
   <button class="btn btn-primary" name="267" type="action">Pending Orders (Test)</button>
</xpath>