0

我创建了从 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>
4

1 回答 1

0

你的课程应该从

模型.模型

所以你的班级签名将是: class ClassProduct(models.Model):

于 2019-05-12T00:47:26.367 回答