0

I have created new model that inherit from product.product, in the python file i have added this function:

class ClassProduct:
    _inherit = 'product.product'
    field1 = fields.Char()

I try to add new field in model product.product but i got this error while restarting server:

File "/home/omar/odoo/odoo12/odoo/models.py", line 1112, in _validate_fields
    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.tools.convert.ParseError: "Error while validating constraint

Field `field1` does not exist

Error context:
View `product.template.common.form.costumized`
[view_id: 2073, xml_id: module.product_template_form_view_costumized, model: product.product, parent_id: 388]
None" while parsing /home/omar/odoo/custom-addons/addons12/module/views/views.xml:305, near
<record id="product_template_form_view_costumized" model="ir.ui.view">
            <field name="name">product.template.common.form.costumized</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@name='inventory']" position="after">
                    <!-- Add your fields or attributes here -->
                    <page string="dxf Viewer">
                        <group>
                            <group>
                                    <!--<field name="choose_dxf_file" widget="image"/>-->
                                    <!--<field name="name"/>-->
                                    <field name="field1"/>
                            </group>
                        </group>
                    </page>
                </xpath>
            </field>
        </record>
Programmer LiLi
  • 147
  • 5
  • 27

1 Answers1

0

your class should extend from

models.Model

so your class signature will be: class ClassProduct(models.Model):

Black Kinght
  • 55
  • 1
  • 10