Hey guys ,
this my first fields selections :
'niveau_kid' : fields.selection([('a', 'Twist and Shout'), ('b', 'Starter Kid'), ('c', 'Sky 1'), ('d', 'Sky 2'), ('e', 'Sky 3'), ('f', 'Upper-intermediate Kid'), ('g', 'Advanced Kid')]),
'grp_kid': fields.selection([('mer1', 'Mercredi 14h - 16h'), ('mer2', 'Mercredi 16h - 18h'), ('ven', 'Vendredi 17h - 19h')], 'Groupe', compute='_return_group_kid'),
and i want that the grp_kid fields depend to niveau_kid
for exemple :
if a is selected , then we can choose in the second field between only two values (mer1 and mer2)
if g is selected then we will have only one choice (ven)
........
------------------------------ i tried this code but it don't work ----------
#@api.one
@api.onchange('niveau_kid')
def _return_group_kid(self):
if not self.niveau_kid:
return
if self.niveau_kid == 'f':
self.grp_kid.selection = [ ('a', 'Mercredi 14h - 16h'), ]
if self.niveau_kid == 'g':
self.grp_kid.selection = [ ('b', 'Mercredi 16h - 18h'), ]
else:
self.grp_kid.selection = [ ('a', 'Mercredi 14h - 16h'), ('b', 'Mercredi 16h - 18h'), ('c', 'Vendredi 17h - 19h'), ]