gpt4 book ai didi

python - 在 Odoo 中设置 Many2one 字段值的域

转载 作者:太空宇宙 更新时间:2023-11-03 17:31:19 26 4
gpt4 key购买 nike

我有 Many2one 字段女巫由 res.partner 模块使用自定义域填充。

当用户从Many2one字段中选择一个值时,我想根据所选值隐藏一些字段。

我试试这个:

<group string="My group name" attrs="{'invisible': [('mym2ofield', 'not ilike', 'mym2ofield value')]}">

但是它不起作用。那我怎样才能实现呢?

最佳答案

首先我们需要在您的模型中添加相关字段。然后在 attrs

中使用新的相关字段

例如:

type 是 Many2one 表中的字符字段。

class model_name(models.Model):
_name = 'model.name'

test_id = fields.Many2one('relation.table.name', string="Many2One Label")
type = fields.Char(related='test_id.type', string="Type")

然后到您的表单:

<group string="group name" attrs="{'invisible': [('type', '!=', 'value')]}">

关于python - 在 Odoo 中设置 Many2one 字段值的域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31802484/

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