gpt4 book ai didi

python - 如何在 Odoo 中以编程方式隐藏字段?

转载 作者:行者123 更新时间:2023-12-01 04:14:41 25 4
gpt4 key购买 nike

我正在尝试为 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 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

最佳答案

您需要打开您声明的 cand_lan_id View .xml 文件。

现在替换字段

<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>

关于python - 如何在 Odoo 中以编程方式隐藏字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34454083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com