Computed fields

Fields can have their values automatically calculated by a function, instead of simply reading a database stored value. A computed field is declared just like a regular field, but has the additional compute argument to define the function used for its computation.

In most cases, computed fields involve writing some business logic. So, to take full advantage of this feature we need to learn the topics explained in Chapter 7, Business Logic - Supporting business processes. We can still explain computed fields here, but will keep the business logic as simple as possible.

Let's work on an example. Stages have a fold field. We will add a computed field with the Folded? flag for the corresponding stage to our To-Do tasks.

We should ...

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.