Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
2170 Представления

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 ?

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Автор Лучший ответ

Thank you !!

This works !

BUT !!


It's deprecated

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

Аватар
Отменить

You can use dynamic domain methods

Related Posts Ответы Просмотры Активность
1
окт. 23
1977
2
авг. 23
4196
4
авг. 23
20523
3
окт. 22
10990
3
мар. 22
37313