I have Many2one field witch is populated by res.partner module using custom domain.
我有使用自定义域的res.partner模块填充了Many2one field witch。
When User selects one of values from Many2one field, I want to hide some fields based on selected value.
当用户从Many2one字段中选择一个值时,我想根据所选值隐藏一些字段。
I try this:
我试试这个:
<group string="My group name" attrs="{'invisible': [('mym2ofield', 'not ilike', 'mym2ofield value')]}">
But it does not work. How could I achieve it then?
但它不起作用。那我怎么能实现呢?
1 个解决方案
#1
1
First we need to add related field in your model. And than use that new related field in attrs
首先,我们需要在模型中添加相关字段。而不是在attrs中使用那个新的相关领域
For example:
例如:
type
is a char field on your many2one table.
type是many2one表上的char字段。
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")
And then to your form:
然后到你的表格:
<group string="group name" attrs="{'invisible': [('type', '!=', 'value')]}">
#1
1
First we need to add related field in your model. And than use that new related field in attrs
首先,我们需要在模型中添加相关字段。而不是在attrs中使用那个新的相关领域
For example:
例如:
type
is a char field on your many2one table.
type是many2one表上的char字段。
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")
And then to your form:
然后到你的表格:
<group string="group name" attrs="{'invisible': [('type', '!=', 'value')]}">