通过视图继承替换已经继承的视图中的字段(Odoo 8)

时间:2015-09-04 10:34:54

标签: inheritance openerp odoo odoo-8 openerp-8

sale_stock模块的sale_stock_view.xml通过继承扩展销售模块中的sale_view.xml,并添加warehouse_id

sale_stock_view.xml:

        <record id="view_order_form_inherit" model="ir.ui.view">
            <field name="name">sale.order.form.sale.stock</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <data>
                    ...
                    <field name="client_order_ref" position="after">
                         <field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" options="{'no_create': True}" groups="stock.group_locations"/>
                    </field>

我想通过带有position="replace"的空字段继承sale_stock模块中的.xml来删除warehouse_id:

我自己模块中的.xml:

<?xml version="1.0" encoding="utf-8"?>
    <openerp>
    <data>
        <record id="view_order_form_inherit_mymodule" model="ir.ui.view">
                <field name="name">sale.stock.sale.order.form.mymodule</field>
            <field name="model">sale_stock.sale_order</field>
            <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>
            <field name="arch" type="xml">
                <field name="warehouse_id" position="replace"/>
            </field>
        </record>
    </data>
</openerp>

错误消息:

ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition

Error details:
Konnte Modell nicht finden: sale_stock.sale_order

Fehler Kontext:
Ansicht `sale.stock.sale.order.form.mymodule`
[view_id: 1470, xml_id: k. A., model: sale_stock.sale_order, parent_id: 783]" while parsing /home/tertia/workspace/odoo8/custom_modules/mymodule/views/sale/sale_view.xml:4, near
<record id="view_order_form_inherit_mymodule" model="ir.ui.view">
                    <field name="name">sale.stock.sale.order.form.mymodule</field>
                    <field name="model">sale_stock.sale_order</field>
                    <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>
                    <field name="arch" type="xml">
                        <field name="warehouse_id" position="replace"/>
                    </field>
                </record>

错误讯息是德语,但会转换为Model could not be found: sale_stock.sale_order 我尝试了各种模型,例如sale_stock.sale_stock.sale_ordersale.order或简单sale_order,但每次尝试都会产生相同的错误消息。

1 个答案:

答案 0 :(得分:1)

在我看来,你想要处理的模型只是sale.order。据我所知,sale_stock模块中没有sale_order模型。