Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Dynamicly hide fields and rows in tree view odoo 9

By
Mohamed
on 11/16/16, 12:12 PM 160 views

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>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/16/16, 12:12 PM
Seen: 160 times
Last updated: 11/16/16, 2:45 PM