验证约束字段“文件”不存在时出错

时间:2019-03-06 14:51:16

标签: odoo-12

我创建了一个从product.product继承的新模型,在python文件中我添加了以下功能:

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

我尝试在模型product.product中添加新字段,但是重新启动服务器时出现此错误:

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>

1 个答案:

答案 0 :(得分:0)

您的课程应该从

开始
  

models.Model

因此您的班级签名将是: class ClassProduct(models.Model):