Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
1831 Weergaven

I have an on_change method that assigns a list of tuples to a Selection field


But I get the error message in the subject

Why is that ?

The tuples are like (int, string)


I tried casting the 2 elements in the tuples to 2 strings, int for the id and string for the value, string for the id and int for the value...


I just want to create a list of choices for a dropdown menu field that depends on the value in another field


How am I supposed to do that ?

Avatar
Annuleer
Beste antwoord

Hi Adriano,

Try this code 

@api.onchange('selection_field')
def _onchange_domain(self):
if self.selection_field == 'value':
domain = [('id', '=', self.id)]
else:
domain = []
return {'domain': {'another_field': domain}}

Also, Check this reference to apply dynamic domain for relational fields 

Dynamic domain


Regards

Avatar
Annuleer
Auteur Beste antwoord

Thank you !!

This works !

BUT !!


It's deprecated

i read here an answer about how to properly do this but I don't understand

Avatar
Annuleer

You can use dynamic domain methods

Gerelateerde posts Antwoorden Weergaven Activiteit
1
okt. 23
1590
2
aug. 23
3669
4
aug. 23
20001
3
okt. 22
10513
3
mrt. 22
36891