This question has been flagged
2 Replies
4563 Views

I've 3 tables 'Adherant' , 'Affilie' and 'Depot' tables. I've 2 fields in my depot form view : adherant and affilie fields they are picked automatically from the corresponding tables. but what I want to do is that when I choose an adherant from the list, I do not want to have all affilie listed in the selection widget, because the affilie field is dependant on the adherant field.

How to get only a subset listed on affilie depending on the adherant field....? browse or name_search ORM methods ...?

Avatar
Discard
Best Answer

You can have a function define the list of possible items to select. There is an example of doing exactly this in the documentation of selection fields take a look in the developers manual.

Avatar
Discard
Author Best Answer

Thank you for your answer, but the example i've seen :

def _get_selection(self, cursor, user_id, context=None):
return (
   ('choice1', 'This is the choice 1'),
   ('choice2', 'This is the choice 2'))

_columns = {

'sel' : fields.selection( _get_selection, 'What do you want ?') }

for example : the adherant list contains 3 people : Amine, Yassine, Karim and each one with its affilie list "one2many field"

Amine(Joe, Daniel, Michael) ; Yassine(Susan, Barbara, yoland) and Karim(Nadir, Nabil, Najm )

How to do the following dynamically :

When I choose Amine for example, I get only the 3 affilies Joe, Daniel, Michael on the second list to choose from; If I choose Yaasine on the adherant field, I should have only the 3 affilies Susan, Barbara, yoland instead of all the affilie that have been created in the affilie table.

I'm really stuck with this, because i do not know how to compare between the adherant name and the object got from the browse function

and how to put my code using the onchange function so that the choice of affilie depends dynamically on the adherant field

Thank you very much !

Avatar
Discard