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 apply filter for one2many field

By
Mohamed
on 11/27/16, 9:33 AM 155 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

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/27/16, 9:33 AM
Seen: 155 times
Last updated: 12/10/16, 2:33 AM