如何在 Odoo 中以编程方式隐藏字段?
How to hide a field programmatically in Odoo?
我正在尝试为 Odoo 制作一个模块,但我不知道如何使用 python 代码隐藏字段
这条线对我不起作用:
'form_id': fields.many2one('dev.test', 'candidat', select=False,invisible=True),
我想使用 python 隐藏它而不是使用 xml 因为我没有在我的 xml 中声明 many2one 字段它只是我测试关系中的一个简单字段,该字段将在弹出窗口内创建以创建新的 "formation".
这是建立关系的字段的定义
'test_form_ids': fields.one2many('dev.form', 'form_id','formations'),
test_form_ids one2many field capture
这是我的阵型class
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
您需要打开您声明的 .xml 文件的视图 cand_lan_id。
现在替换字段
<field name="cand_lan_id"/>
和
<field name="cand_lan_id" invisible="1"/>
invisible="1" 是对用户隐藏您的字段的属性。
编辑:
打开 .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>
我正在尝试为 Odoo 制作一个模块,但我不知道如何使用 python 代码隐藏字段 这条线对我不起作用:
'form_id': fields.many2one('dev.test', 'candidat', select=False,invisible=True),
我想使用 python 隐藏它而不是使用 xml 因为我没有在我的 xml 中声明 many2one 字段它只是我测试关系中的一个简单字段,该字段将在弹出窗口内创建以创建新的 "formation".
这是建立关系的字段的定义
'test_form_ids': fields.one2many('dev.form', 'form_id','formations'),
test_form_ids one2many field capture
这是我的阵型class
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
您需要打开您声明的 .xml 文件的视图 cand_lan_id。
现在替换字段
<field name="cand_lan_id"/>
和
<field name="cand_lan_id" invisible="1"/>
invisible="1" 是对用户隐藏您的字段的属性。
编辑:
打开 .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>