콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
2541 화면

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

관련 게시물 답글 화면 활동
1
10월 23
2313
2
8월 23
4661
4
8월 23
21021
3
10월 22
11395
3
3월 22
37598