O'Reilly logo

Odoo Development Essentials by Daniel Reis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Computed fields

Fields can have values calculated by a function, instead of simply reading a database stored value. A computed field is declared just like a regular field, but has an additional argument compute with the name of the function used to calculate it.

In most cases computed fields involve writing some business logic, so we will develop this topic more in Chapter 7, ORM Application Logic - Supporting Business Processes. We can still explain them here, but keeping the business logic side as simple as possible.

Let's work on an example: stages have a fold field. We will add to tasks a computed field with the Folded? flag for the corresponding stage.

We should edit the TodoTask model in the todo_ui/todo_model.py file to add the following: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required