在 Odoo 中的 Many2one 字段值上设置域
Set domain on Many2one field value in Odoo
我有 Many2one 字段 由 res.partner 模块使用自定义域填充。
当用户从 Many2one 字段中选择一个值时,我想根据所选值隐藏一些字段。
我试试这个:
<group string="My group name" attrs="{'invisible': [('mym2ofield', 'not ilike', 'mym2ofield value')]}">
但是不行。那我怎么能实现呢?
首先我们需要在您的模型中添加相关字段。而不是在 attrs
中使用新的相关字段
例如:
type
是您的 many2one table.
上的一个字符字段
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')]}">
我有 Many2one 字段 由 res.partner 模块使用自定义域填充。
当用户从 Many2one 字段中选择一个值时,我想根据所选值隐藏一些字段。
我试试这个:
<group string="My group name" attrs="{'invisible': [('mym2ofield', 'not ilike', 'mym2ofield value')]}">
但是不行。那我怎么能实现呢?
首先我们需要在您的模型中添加相关字段。而不是在 attrs
例如:
type
是您的 many2one table.
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')]}">