python - 如何解决“无法读取未定义的属性‘字段’”
问题描述
我创建了一个自定义模块来在产品模板中添加字段构造函数。我正在使用 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>
产品.py
from openerp import fields, models,
_inherit = 'product.template'
constructor = fields.Char(string="Constructeur")
解决方案
将字段名称构造函数重命名为任何其他名称,然后重试。
推荐阅读
- java - 使用 (int)(1+(Math.random()*16)) 选择任何 3 个索引时,选择 17 个元素列表的 3 个特定索引的概率是多少
- postgresql - 如何使用 plpgsql 将服务器上的文件移动到另一个目录?
- c# - 在 `Task.Run` 中使用 `Result` 的有效性如何
- php - Laravel SQLSTATE[HY000] [2002] 当“控制器”中的命令但在 Tinker 中正常显示时,连接被拒绝
- c - 返回字符串长度小于输入字符串长度
- javascript - 在类中使用扩展类的方法
- java - 滚动时 ListAdapter 出现问题
- python - Python - Pygame - 为什么没有检测到碰撞?
- java - java应用程序中的全局Catch子句
- algorithm - 计算累积异或小于 k 的子集数