Skip to Content
मेन्यू
This question has been flagged
3 Replies
7971 Views

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.

Avatar
Discard

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

Best Answer

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') 

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
1
मार्च 15
5507
0
जून 15
3152
2
अग॰ 24
2404
2
जून 19
2914
0
मार्च 24
3374