you can use the @api.onchange decorator to trigger a method that updates the total_amount field.
from odoo import api, fields, models
class SyndicPaiement(models.Model):
_name = "syndic.paiement"
total_amount = fields.Float(string='Total Amount', compute="_compute_montant_total")
received_amount = fields.Float(string='Received Amount')
@api.depends('received_amount')
def _compute_montant_total(self):
for record in self:
record.total_amount = sum(record.received_amount for record in self)
@api.onchange('received_amount')
def _onchange_received_amount(self):
self._compute_montant_total()
In this example, we define the total_amount field as a computed field with the compute attribute set to _compute_montant_total. The _compute_montant_total method sums up the received_amount values for all records in the current set.
The @api.onchange('received_amount') decorator is used for the received_amount field. Whenever the received_amount field is changed, the _onchange_received_amount method is triggered, which in turn calls the _compute_montant_total method to update the total_amount field.
Thank you for your help but it still send me this message:
Thanks
see if the function _compute_montant_total is added syndic.paiement model and service has been restarted