How i can use correctly` Eval` feature

Hi how i can use correctly Eval feature

i have a field ,which i want it to be disappear after a selected of a special attribute of another field type selection.

performance= fields.Selection([
        ('law', 'LAW L'),
        ('higher', 'HIGHER T'),
        ('equal, 'EQUALITY'),
    ], 'Performance', readonly = False,select=True)

gradient = fields.Float("Gradient",states={'invisible': Eval('performance') == 'law' or Eval('performance') == 'higher' }, 

there was no error but also no result , the field “gradient” still be displayed when i select anything from the selection ,so list did i miss something to do it in the field “gradient” to get my goal !

You can not use the Python or in PYSON statement, you must use the PYSON.OR (or the Python operation |).

yeah thank you i did by using the operation | , but until now , there is no result , still did not disappear from the form view

i change it like that :

gradient = fields.Float("Gradient",states={'invisible':(
~Eval('performance') == 'law' | (Eval('performance') == 'higher'))}, depends=['performance'])

Is there another thing i must do it or declare it !

This expression is always False because ~Eval('performance') is always True or False so it is always different from 'law'.

Good morning so what i must do !


You need to remove the ~, so you want something like:

    'invisible': (
        (Eval('performance') == 'law')
        | (Eval('performance') == 'higher')),

Or alternatively you can use in_():

    'invisible': Eval('performance').in_(['law', 'higher']),
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.