我正在尝试为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'),
这是我的编队课
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),
}
高亮显示我要隐藏的字段,弹出窗口以创建新的编队捕获
您需要打开您声明的cand_lan_id的view .xml文件。
现在替换字段
<field name="cand_lan_id"/>
和
<field name="cand_lan_id" invisible="1"/>
invisible =“ 1”是将对用户隐藏您的字段的属性。
编辑:
打开其中声明了test_form_ids字段的.xml文件。
现在替换字段
<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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句