i want to get the sum of amount's values of in a computed field in event.event model
class EventEvent(models.Model): _inherit = 'event.event' birst_ids = fields.Many2many('hr.birst', string='field name') class FleetList(models.Model): _name = 'hr.birst' bricom = fields.Char('field name") amount = fields.Float('Montant')
how can i get a computed field in the event.event model that has as a value the sum of amount value field ?
i tried this code but it seems that i am still missing something
class EventEvent(models.Model): _inherit = 'event.event' birst_ids = fields.Many2many('hr.birst', string='field name') def _amount_total (self, cr, uid, ids, field_name, arg, context=None): res = {} for event in self.browse(cr, uid, ids, context=context): total = 0.0 for ids in event.birst_ids: total += ids.amount res[event.id] = total return res total_amount = fields.Float(computed="_amount_total", sting="Total")
any help ?
thanks Niyas for your replay, but still the total_amount field dosent filled up with the sum of amount's values,