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

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.

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
мар. 15
5449
0
июн. 15
3107
2
авг. 24
2341
2
июн. 19
2834
0
мар. 24
3301