ValidateError Error occurred while validating the field(s) arch: Invalid XML for View Architecture

StackOverflow https://stackoverflow.com/questions/21545921

  •  06-10-2022
  •  | 
  •  

Question

init.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>

Showing :

ValidateError Error occurred while validating the field(s) arch: Invalid XML for View Architecture. Try all other stackoverflow solution or similar solution. But still stuck.

Was it helpful?

Solution 2

update your xml file,

  <?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>

Hope this will give you desired output. Don't forget to update your module.

OTHER TIPS

There is no field called partner_id in that form you r inheriting & also inherit must be module.xml_id not view name

See for example:

<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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top