将“已开票”智能按钮添加到销售订单

时间:2017-05-13 14:21:53

标签: xml openerp odoo-10

我正在使用Odoo 10,当我在销售订单中选择客户时,我想在客户页面上显示智能按钮。 enter image description here

我在另一个关于向产品页面添加智能按钮的论坛上发现了这一点,我正在尝试将其用于销售订单页面。

<record id="view_product_invoice_line_tree" model="ir.ui.view">
            <field name="name">product.account.invoice.line.tree</field>
            <field name="model">account.invoice.line</field>
            <field name="arch" type="xml">
                <tree string="Invoice Line">
                    <field name="invoice_id"/>
            <field name="product_id"/>
                    <field name="account_id"/>
                    <field name="quantity"/>
                    <field name="uom_id"/>
                    <field name="price_unit"/>
                    <field name="discount"/>
                    <field name="price_subtotal"/>
                    <field name="currency_id" invisible="1"/>
                </tree>
            </field>
        </record>
        <record model="ir.actions.act_window" id="action_inv_line_product_tree">
            <field name="context">{}</field>
            <field name="domain">[('product_id','in',active_ids)]</field>
            <field name="name">Invoices</field>
            <field name="res_model">account.invoice.line</field>
            <field name="view_id" ref="view_product_invoice_line_tree"/>
        </record>
        <record id="view_product_template_invoice_buttons_from" model="ir.ui.view">
            <field name="name">product.template.invoice.button.inherit</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_only_form_view"/>
            <field name="arch" type="xml">
                <div name="button_box" position="inside">
                   <button class="oe_stat_button" name="%(account.action_inv_line_product_tree)d"
                       type="action" icon="fa-shopping-cart">Invoices
                   </button>
                </div>
            </field>
        </record>

这是我的xml文件

<odoo>
    <data>


<!-- Inherit Form View to Modify it -->
<record id="saleorder_buttons_inherit" model="ir.ui.view">
    <field name="name">saleorder.buttons.inherit</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">



            <xpath expr="//field[@name='partner_id']" position="after">
               <field name="new_testfield"/>
            <!-- Add your fields or attributes here -->
        </xpath>

    </field>
</record>
<record id="view_product_invoice_line_tree" model="ir.ui.view">
            <field name="name">product.account.invoice.line.tree</field>
            <field name="model">account.invoice.line</field>
            <field name="arch" type="xml">
                <tree string="Invoice Line">
                    <field name="invoice_id"/>
            <field name="product_id"/>
                    <field name="account_id"/>
                    <field name="quantity"/>
                    <field name="uom_id"/>
                    <field name="price_unit"/>
                    <field name="discount"/>
                    <field name="price_subtotal"/>
                    <field name="currency_id" invisible="1"/>
                </tree>
            </field>
        </record>
        <record model="ir.actions.act_window" id="action_inv_line_product_tree">
            <field name="context">{}</field>
            <field name="domain">[('partner_id','in',active_ids)]</field>
            <field name="name">Invoices</field>
            <field name="res_model">account.invoice.line</field>
            <field name="view_id" ref="sale.view_order_form"/>
        </record>
        <record id="view_product_template_invoice_buttons_from" model="ir.ui.view">
            <field name="name">sale.order.invoice.button.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.order_template_only_form_view"/>
            <field name="arch" type="xml">
                <div name="button_box" position="inside">
                   <button class="oe_stat_button" name="%(account.action_inv_line_product_tree)d"
                       type="action" icon="fa-shopping-cart">Invoices
                   </button>
                </div>
            </field>
        </record>


    </data>
    </odoo>

我得到的错误是

    raise ValueError('External ID not found in the system: %s' % xmlid)
ParseError: "External ID not found in the system: sale.order_template_only_form_view" while parsing /home/jason/customaddons/buttons_sales_order/templates.xml:45, near
<record id="view_product_template_invoice_buttons_from" model="ir.ui.view">
            <field name="name">sale.order.invoice.button.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.order_template_only_form_view"/>
            <field name="arch" type="xml">
                <div name="button_box" position="inside">
                   <button class="oe_stat_button" name="%(account.action_inv_line_product_tree)d" type="action" icon="fa-shopping-cart">Invoices
                   </button>
                </div>
            </field>
        </record>

1 个答案:

答案 0 :(得分:0)

错误表示sale.order_template_only_form_view视图不存在。

我认为您已将 product.product_template_only_form_view 更改为 sale.order_template_only_form_view

它不起作用product.product_template_only_form_view是产品模块中product_template_only_form_view的外部ID。