1
votes

I have Many2one field witch is populated by res.partner module using custom domain.

When User selects one of values from Many2one field, I want to hide some fields based on selected value.

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 Answers

1
votes

First we need to add related field in your model. And than use that new related field in attrs

For example:

type is a char field on your 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")

And then to your form:

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