Hey Cyllo community! Quick question: When exactly do computed fields update? Is it real-time, or only on save/refresh? Thanks in advance!
Welcome!
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
This question has been flagged
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