Odoo Help

0

Dynamicly apply filter for one2many field

By
Mohamed
on 11/27/16, 9:33 AM 438 views

I need to filter records shown in one2many tree when I click a button or change another field

I have tried tens of times with different techniques but it doesn't work

here is the last try to figure out the problem

first in the main model

current_exercise = 'exercise 1'
generalFitnessDetails = One2many("spogaze.general_fitness_details", "generalFitnessDetails", domain=[('exercise', '=', '%s' % current_exercise)])

the detailed model which represented with O2M field has 'exercise' field which I need to apply the filter depends on it

in the main model I added a function to change the 'current_exercise' value and applying the filter

@api.one    
def next_exercise(self):
self.current_exercise = 'exercise 2'
return {'domain': {'generalFitnessDetails': [('exercise', '=', self.current_exercise)]}}

but what happens is that the first filter applied which is stated in O2M field creation before I click the button, but after clicking the button the field "current_exercise" changes but filter doesn't apply

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 11/27/16, 9:33 AM
Seen: 438 times
Last updated: 12/10/16, 2:33 AM