I have model to store training results for athletes and tree view to insert results from
what I need is to create a button where it's function is : onClick , it filters the visibility of the shown columns in the tree view according to the exercise state ; so that if the exercise state's value is "by_distance" then it shows only the column that holds the values of by distance
Also the visibility have to be automatically changed so that if the exercise state becomes "by_weight" it changes to it and so on .
code :
class GeneralFitnessDetails(Model):
_name = 'general_fitness_details'
generalFitnessDetails = Many2one("general_fitness")
player = Many2one('player')
exercise = Many2one("exercise")
exercise_state = Selection([('by_reps', 'By Reps'),
('by_time', 'By Time'),
('by_distance', 'By Distance'),
('by_weight', 'By Weight')])
reps = Integer(string='Reps')
time_sec = Integer(string='Seconds')
weight = Integer(string='Weight/KG')
distance = Integer(string='Distance/Meters')
<tree>
<field name="player"/>
<field name="exercise"/>
<field name="exercise_state"/>
<field name="reps" invisible="[('exercise_state', '=', 'by_reps')]"/>
<field name="time_sec" invisible="[('exercise_state', '=', 'by_time')]"/>
<field name="weight" invisible="[('exercise_state', '=', 'by_weight')]"/>
<field name="distance" invisible="[('exercise_state', '=', 'by_distance')]"/>
</tree>