Search code examples
odooodoo-12

Make invisible a field when one of the options is true in Odoo


I want to make invisible a field if one of those options are true, I don't know if this is possible. I try:

<field name="x_field1" string="something" attrs="{'invisible': [('x_field2','!=','value'),'|',('x_field3','=','value'),'|',('x_field4','=','value')]}"/>

And this:

<field name="x_field1" string="something" attrs="{'invisible': ['|',('x_field2','!=','value'),('x_field3','=','value'),('x_field4','=','value')]}"/>

Without success.


Solution

  • From Odoo Domains documentation:

    '|'
    logical OR, arity 2.

    You have three options, so you need to use two | operators, like the following:

    ['|', '|', ('x_field2', '!=', 'value'), ('x_field3', '=', 'value'), ('x_field4', '=', 'value')]