【发布时间】:2016-05-24 11:28:25
【问题描述】:
我为产品创建了几个自定义字段。产品出现在销售、采购、仓库和制造模块中。我想让我的自定义字段只出现在制造模块中并隐藏在其他任何地方。那么如何对不可见属性设置条件。我试过这样,得到错误Unknown field _name in domain
attrs="{'invisible': [('_name', '!=', 'mrp.bom')]}"
Python 文件,
from openerp import fields,models, api
class product_template(models.Model):
_inherit = "product.template"
rim_weight = fields.Float(string='Rim Weight(KG)', readonly=True, compute='_compute_one_rim_weight')
width = fields.Float(string='Width(cm)',default='50')
length = fields.Float(string='Length(cm)',default='63')
gsm = fields.Float(string='Gram per square meter(gsm)',default='230')
Xml 文件,
<record id="product_template_form_view_dis_inherit" model="ir.ui.view">
<field name="name">product.template.common.form.dis.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[@string='Accounting']" position='after'>
<page string='Cover Page Paper'>
<group>
<field name="width"/>
<field name="length"/>
<field name="gsm"/>
<field name="rim_weight"/>
</group>
</page>
</xpath>
</field>
</record>
【问题讨论】: