Sometimes you need to refer to the relation of a relation. For example,
supposing you have objects: City -> State -> Country, and you need to refer to
the Country from a City, you can define a field as below in the City object:
'country_id': fields.related(
'state_id',
'country_id',
type="many2one",
relation="res.country",
string="Country",
store=False)
- Where:
- The first set of parameters are the chain of reference fields to
follow, with the desired field at the end.
- type is the type of that desired field.
- Use relation if the desired field is still some kind of
reference. relation is the table to look up that
reference in.
|