Related fields
The computed field we implemented in the previous section just copies a value from a related record into a model's own field. This is a common use case that can be automatically handled by Odoo using the related field feature.
Related fields make available, directly in a model, fields that belong to a related model and are accessible using a dot notation chain. This makes them available in situations where dot notation can't be used, such as UI form views.
To create a related field, we declare a field of the required type, just like with regular computed fields, but instead of compute we use the related attribute, setting it with the dot notation field chain to reach the desired field.
We can use a reference field to get the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access