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 ...

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.