i have created a new many2one field in product.category model which relates to stock.warehouse in python file.Then i created the following view.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Inherit Form View to Modify it -->
<record id="product_category_warehouse" model="ir.ui.view">
<field name="name">product.category.Warehouse</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/group/group//field[@name='property_cost_method']" position="after">
<field name="warehouse_id" options="{'no_quick_create': True, 'no_create_edit' : True}"/>
</xpath>
</field>
</record>
when I installed this module. this module successfully installed and the field is shown after property_cost_method field. but when I upgrade the module it throwing errors as below. Note: if I uninstall and then reinstall the module it installed successfully again. what causes that behavior?
File "/home/babar/odoo12/odoo/odoo/models.py", line 1132, in _validate_fields raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e))) odoo.tools.convert.ParseError: "Error while validating constraint Element '<xpath expr="/form/sheet/group/group//field[@name='property_cost_method']">' cannot be located in parent view Error context: View `product.category.Warehouse` [view_id: 1690, xml_id: apn_product_category_warehouse.product_category_warehouse, model: product.category, parent_id: 421] None" while parsing /home/babar/linux/Custom_module/Athena/apn_product_category_warehouse/views/views.xml:6, near <record id="product_category_warehouse" model="ir.ui.view"> <field name="name">product.category.Warehouse</field> <field name="model">product.category</field> <field name="inherit_id" ref="product.product_category_form_view"/> <field name="arch" type="xml"> <xpath expr="/form/sheet/group/group//field[@name='property_cost_method']" position="after"> <field name="warehouse_id" options="{'no_quick_create': True, 'no_create_edit' : True}"/> </xpath> </field> </record>