我正在尝试在制造模块的产品屏幕上添加一个标签。该标签应该看起来像这样:Product Part Detail Tab
我创建了一个自定义模块,并在尝试安装时遇到错误:
“ParseError:”ValidateError
字段arch
对约束失败:视图定义无效
错误详情:
字段x_mfrpn
不存在“
下面是我的代码,我意识到它是OpenERP的更高版本的语法,但是在我尝试向其添加“class sub_part_detail”之前,该模块正常工作。
from openerp.osv import osv, fields
class product_part_detail(osv.osv):
_name = 'product.part.detail'
_inherit = 'product.template'
_columns = {
'x_mfrpn': fields.char('P/N'),
'product_part_detail': fields.one2many('sub.part.detail','sub_part_detail')
}
class sub_part_detail(osv.osv):
_name = 'sub.part.detail'
_inherit = 'product.part.detail'
_columns = {
'x_bomcategory': fields.char('Category'),
'x_primarypn': fields.boolean('Primary PN'),
'x_obsolete': fields.boolean('Obsolete'),
'x_mfrname': fields.char('MFR'),
'x_pndescription': fields.char('Description'),
'x_pnupgrade': fields.char('Upgrade'),
'x_pnnotes': fields.text('Notes'),
'sub_part_detail': fields.many2one('product.part.detail')
}
这是我的xml
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="product_part_detail">
<field name="name">product.template.product.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="//page[@string='Accounting']" position="after">
<page string="Part Detail">
<field name="x_mfrpn" />
</page>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="sub_part_detail">
<field name="arch" type="xml">
<field name="x_mfrpn" position="after">
<field name="x_bomcategory" />
<field name="x_primarypn" />
<field name="x_obsolete" />
<field name="x_mfrname" />
<field name="x_pndescription" />
<field name="x_pnupgrade" />
<field name="x_pnnotes" />
</field>
</field>
</record>
</data>
答案 0 :(得分:0)
<record model="ir.ui.view" id="sub_part_detail">
<field name="name">sub.part.detail..form</field>
<field name="model">sub.part.detail</field>
<field name="arch" type="xml">
<field name="x_bomcategory" />
<field name="x_primarypn" />
<field name="x_obsolete" />
<field name="x_mfrname" />
<field name="x_pndescription" />
<field name="x_pnupgrade" />
<field name="x_pnnotes" />
</field>
</record>
也不需要写_inherit =&#39; product.template&#39;和 _inherit =&#39; product.part.detail&#39;在py文件中