簡體   English   中英

Odoo10 xpath繼承采購訂單行上的字段

[英]Odoo10 xpath inherit field on purchase order line

我正在嘗試在模塊上編碼。

但是我被卡住了。 它不起作用。

Python代碼

class PurchaseCurrency(models.Model):
    _inherit = "purchase.order.line"

    new_currency = fields.Float(string="Test")

我的xml

<record id="new_currency_line" model="ir.ui.view">
        <field name="name">purchase.order.form</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='order_line']/tree/field[@name='product_qty']" position="after">
                <field name="new_currency"/>
            </xpath>
        </field>
</record>

和錯誤警告

ValueError:字段new_currency不存在

錯誤內容:查看purchase.order.form [view_id:1074,xml_id:purchase.purchase_order_form,模型:purchase.order,parent_id:n / a]

有人可以幫助我嗎?

將您的python模型文件從添加到__init__.py 導入模型

確保您的python模型目錄從導入到模塊根__init__.py中。 導入模型

重新啟動odoo實例並從Web后端或從命令行使用-u module_name更新模塊。

您可以使用field標簽簡化xpath表達式

<record id="new_currency_line" model="ir.ui.view">
    <field name="name">purchase.order.form.new</field>
    <field name="model">purchase.order</field>
    <field name="inherit_id" ref="purchase.purchase_order_form" />
    <field name="arch" type="xml">
    <field name="product_qty" position="after">
        <field name="new_currency" />
    </field>
</record>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM