如何解决"Cannot read property 'fields' of undefined"
How to resolve "Cannot read property 'fields' of undefined"
我创建了一个自定义模块来在产品模板中添加字段构造函数。我正在使用 odoo 9 。我的字段已添加到视图中,但当我想修改旧产品或创建新产品时,它会显示此错误。有什么帮助吗?
Uncaught TypeError: Cannot read property 'fields' of undefined
http://localhost:8069/web/static/src/js/views/form_view.js:496
Retraçage :
TypeError: Cannot read property 'fields' of undefined
at http://localhost:8069/web/static/src/js/views/form_view.js:496:29
at Function._.each._.forEach (http://localhost:8069/web/static/lib/underscore/underscore.js:150:9)
at http://localhost:8069/web/static/src/js/views/form_view.js:495:15
at Function._.each._.forEach (http://localhost:8069/web/static/lib/underscore/underscore.js:150:9)
at Class._build_onchange_specs (http://localhost:8069/web/static/src/js/views/form_view.js:474:11)
at Class.do_onchange (http://localhost:8069/web/static/src/js/views/form_view.js:525:18)
at Class.<anonymous> (http://localhost:8069/web/static/src/js/views/form_view.js:1213:22)
at Class.trigger (http://localhost:8069/web/static/src/js/framework/mixins.js:222:31)
at Class.trigger (http://localhost:8069/web/static/src/js/framework/mixins.js:272:42)
at Class.<anonymous> (http://localhost:8069/web/static/src/js/views/form_common.js:664:18)
product_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_constructor_template_form_view" model="ir.ui.view">
<field name="name">product.constructor.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='type']" position="after">
<field name="constructor"/>
</xpath>
</field>
</record>
</data>
</openerp>
product.py
from openerp import fields, models,
_inherit = 'product.template'
constructor = fields.Char(string="Constructeur")
将字段名称构造函数重命名为任何其他名称,然后重试。
我创建了一个自定义模块来在产品模板中添加字段构造函数。我正在使用 odoo 9 。我的字段已添加到视图中,但当我想修改旧产品或创建新产品时,它会显示此错误。有什么帮助吗?
Uncaught TypeError: Cannot read property 'fields' of undefined
http://localhost:8069/web/static/src/js/views/form_view.js:496
Retraçage :
TypeError: Cannot read property 'fields' of undefined
at http://localhost:8069/web/static/src/js/views/form_view.js:496:29
at Function._.each._.forEach (http://localhost:8069/web/static/lib/underscore/underscore.js:150:9)
at http://localhost:8069/web/static/src/js/views/form_view.js:495:15
at Function._.each._.forEach (http://localhost:8069/web/static/lib/underscore/underscore.js:150:9)
at Class._build_onchange_specs (http://localhost:8069/web/static/src/js/views/form_view.js:474:11)
at Class.do_onchange (http://localhost:8069/web/static/src/js/views/form_view.js:525:18)
at Class.<anonymous> (http://localhost:8069/web/static/src/js/views/form_view.js:1213:22)
at Class.trigger (http://localhost:8069/web/static/src/js/framework/mixins.js:222:31)
at Class.trigger (http://localhost:8069/web/static/src/js/framework/mixins.js:272:42)
at Class.<anonymous> (http://localhost:8069/web/static/src/js/views/form_common.js:664:18)
product_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_constructor_template_form_view" model="ir.ui.view">
<field name="name">product.constructor.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='type']" position="after">
<field name="constructor"/>
</xpath>
</field>
</record>
</data>
</openerp>
product.py
from openerp import fields, models,
_inherit = 'product.template'
constructor = fields.Char(string="Constructeur")
将字段名称构造函数重命名为任何其他名称,然后重试。