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

hi, i m read this documentation. and found the related field so i want to understand actually how to use related field in country->state->city example.

아바타
취소

you want to fetch country name from state->country?

베스트 답변

I normally use related fields only if I need some value from a parent model (M2O) to use it a view. Like when using domain filters, making fields invisible/readonly, itd.. Else just use M2O fields. Even with related fields you need a M2O field to use it in relate. 

For your example I think you can't the way you want. The res_country_state model has the country_id, so you could get the country name from the res_country_state model and not the other way around. 

country_name = fields.Char(relate='country_id.name') 

아바타
취소
베스트 답변

You do not need to create related field you just use many2one field to access it.

아바타
취소
관련 게시물 답글 화면 활동
1
3월 15
5622
0
6월 15
3271
2
8월 24
2548
2
6월 19
3014
0
3월 24
3470