验证字段arch时发生ValidateError错误:View Architecture的XML无效

时间:2014-02-04 06:59:08

标签: python xml openerp openerp-7

初始化的.py

import product_extension

OpenERP的的.py

    {
    'name': "Product Extension",
    'version': "1.0",
    'author': "iologic",
    'category': "product",
    'depends': ['product'],
    'data': ['product_extension.xml'],
    'demo': [],
    'installable': True,
}

product_extension.py

    from openerp.osv import fields, osv

class product_extension(osv.osv):

  _inherit = "product.product"

  _columns = {
    'product_extension_style_number': fields.integer('Style Number', size=20)
    'product_extension_where_used': fields.char('Where Used', size=20)
    'product_extension_est_yield': fields.integer('Est. Yield', size=20)
    'product_extension_cost_dz': fields.integer('Cost Dz', size=20)
  }

product_extension();

product_extension.xml

    <?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="product_extension_product">
        <field name="name">product.normal.form</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.normal.form" />
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/group[2]/field[@name='partner_id']" position="after">
                <field name="product_extension_style_number" />
            </xpath>
        </field>
    </record>


    <record model="ir.ui.view" id="product_extension_product">
        <field name="name">product.normal.form</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.normal.form" />
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/group[3]/field[@name='partner_id']" position="after">
                <field name="product_extension_where_used" />
            </xpath>
        </field>
    </record>

    <record model="ir.ui.view" id="product_extension_product">
        <field name="name">product.normal.form</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.normal.form" />
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/group[4]/field[@name='partner_id']" position="after">
                <field name="product_extension_est_yield" />
            </xpath>
        </field>

       <record model="ir.ui.view" id="product_extension_product">
        <field name="name">product.normal.form</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.normal.form" />
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/group[5]/field[@name='partner_id']" position="after">
                <field name="product_extension_cost_dz" />
            </xpath>
        </field>



    </record>
  </data>
</openerp>

显示:

ValidateError验证字段arch时发生错误:View Architecture的XML无效。尝试所有其他stackoverflow解决方案或类似的解决方案。但仍然卡住了。

2 个答案:

答案 0 :(得分:1)

您继承的形式中没有名为partner_id的字段。还继承必须是module.xml_id而不是视图名称

参见例如:

<record model="ir.ui.view" id="product_extension_product">
    <field name="name">product.normal.form</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view" />
    <field name="arch" type="xml">
        <xpath expr="/form/sheet/notebook/pages[@string="Information"/group/group/field[@name='type']" position="after">
            <field name="product_extension_style_number" />
            <field name="product_extension_where_used" />
            <field name="product_extension_est_yield" />
             <field name="product_extension_cost_dz" />
        </xpath>
    </field>
</record

答案 1 :(得分:0)

更新你的xml文件,

  <?xml version="1.0" encoding="utf-8"?>
  <openerp>
  <data>
  <record model="ir.ui.view" id="product_extension_product">
    <field name="name">product.normal.form</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='partner_id']" position="after">
            <field name="product_extension_style_number"/>
            <field name="product_extension_where_used"/>
            <field name="product_extension_est_yield"/>
            <field name="product_extension_cost_dz"/>
        </xpath>
    </field>
 </record>
 </data>
 </openerp>

希望这会给你想要的输出。不要忘记更新您的模块。