Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
11 Views

Hey Cyllo community! Quick question: When exactly do computed fields update? Is it real-time, or only on save/refresh? Thanks in advance!

Avatar
Discard

Here's how you can use the '@api.depends' decorator effectively in Odoo computed fields. This example shows a basic implementation and explains how it works. The '@api.depends' decorator is crucial for computed fields. It specifies the fields that a computed method depends on, ensuring that the method is triggered to recalculate when any of these dependent fields are changed. class CustomModel(models.Model): _name = 'custom.model' my_field = fields.Integer(compute='_compute_my_field') @api.depends('other_field') def _compute_my_field(self): for record in self: record.my_field = record.other_field * 2

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!