Setting the field invisible on multiple condition using state

i am trying to show a image field when a particular value is selected

    test_name = fields.Selection([
    ('dft', 'DFT'),
    ('adhesion', 'Adhesion Test'),
    ('color', 'Color'),
    ('visual', 'Visual'),
    ], "Test Name")

image = fields.Binary('Image', states = {'invisible': Eval('test_name') != 'dft' or Eval('test_name') != 'adhesion' })

i tried the above code but it does not seems to work

any heads up where am i doing it wrong ?

In the PYSON expression I think you need to use a | instead of or.

However, I still don’t think that will work because it looks like your expression will always evaluate to true, so you might want to use and instead of or and you do this with the & operator.

… and

  • you should add depends=['test_name']
  • you could use the In operator like this ~Eval('test_name').In_(['dft', 'adhesion'])
1 Like