我正在尝试为Odoo创建一个模块,我不知道如何使用python代码隐藏字段 这条线对我不起作用:
'form_id': fields.many2one('dev.test', 'candidat', select=False,invisible=True),
我想使用python隐藏它而不使用xml因为我没有在我的xml中声明many2one字段它只是我测试关系中的一个简单字段,该字段将在弹出窗口中创建以创建新的“形成”
这是建立关系的字段的定义
'test_form_ids': fields.one2many('dev.form', 'form_id','formations'),
test_form_ids one2many field capture
这是我的形成课
class dev_form(osv.Model):
_name='dev.form'
_description='rel between test & formations'
_columns = {
'name': fields.many2one('dev.name', 'Formation'),
'form_id': fields.many2one('dev.test', 'candidat', select=False,invisible=True),
}
突出显示我要隐藏的字段 the popup to create new formation capture
答案 0 :(得分:1)
您需要打开视图 .xml 文件,其中您声明了 cand_lan_id 。
现在替换字段
<field name="cand_lan_id"/>
与
<field name="cand_lan_id" invisible="1"/>
invisible =&#34; 1&#34; 是隐藏用户字段的属性。
编辑:
打开.xml文件,其中声明 test_form_ids 字段。
现在替换字段
<field name="test_form_ids"/>
与
<field name="test_form_ids">
<form string="Form Name">
<field name="name"/>
<field name="form_id" invisible="1"/>
<!-- List of field that User want to see in form view -->
</form>
<tree string="Form Name" editable="bottom">
<field name="name"/>
<!-- List of field that User want to see as a columns -->
</tree>
</field>