我将自定义字段添加到order.sale表单中,但是可以显示错误变量的安装模块字段detail
不存在
这是xml代码:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="detail_field_in_view">
<field name="name">New Sale Order field detail</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/form/group/group/field[@name='price_unit' ]" position="before">
<field name="detail" />
</xpath>
</field>
</record>
</data>
</openerp>
这是.py代码:
from openerp.osv import fields, osv
class test_res(osv.osv):
_inherit = ['sale.order','product.product']
_columns = {
'detail': fields.text('Detail'),
}
答案 0 :(得分:1)
如果要在Order行中添加任何字段,而不是在sale.order.line
对象下定义该字段。因为在sale.order,
字段order_line
与sale.order.line
尝试使用此代码:
from openerp.osv import fields, osv
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
_columns = {
'detail': fields.text('Detail'),
}
这是xml代码:
<record model="ir.ui.view" id="detail_field_in_view">
<field name="name">New Sale Order field detail</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/form/group/group/field[@name='price_unit' ]" position="before">
<field name="detail" />
</xpath>
</field>
</record>