Recalculate computed fields in Odoo 13

David James

Recomputing calculated fields has never been clearly documented in Odoo's developer documentation, and that's still the case in version 13.

Prior to version 13, to recompute a computed field you would flag the fields for re-computation and then call the recompute method on the model. Let's say we want to recalculate the display_name field on all res.partner records, prior to version 13 it would look like this:

partner_obj = self.env['res.partner']

However in version 13 the add_todo method has been removed and the add_to_compute method has been introduced. There is no need to call the recompute method anymore.

The way to recompute calculated fields is now as follows:

partner_obj = self.env['res.partner']