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' },
depends=['performance'])
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 !
ced
(Cédric Krier)
May 26, 2021, 3:13pm
2
You can not use the Python or in PYSON statement, you must use the PYSON.OR (or the Python operation |).
ced:
|
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 !
ced
(Cédric Krier)
May 26, 2021, 6:59pm
4
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 !
dave
(David Harper)
May 27, 2021, 9:23am
6
Hi,
You need to remove the ~, so you want something like:
states={
'invisible': (
(Eval('performance') == 'law')
| (Eval('performance') == 'higher')),
}
Or alternatively you can use in_():
states={
'invisible': Eval('performance').in_(['law', 'higher']),
}
1 Like
system
(system)
Closed
June 26, 2021, 9:24am
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.