Hello, I have Odoo8.
In a model A I have a One2many field and a Many2many field. The related models has fields which are float values. I want to add a computed field in the model A that sums all the float values of the other two models related. How can I do?
I do this but not works (in cases return value 0 and in cases only one value, not the sum)
@api.one
@api.depends('pays')
def _actualiza_monto(self):
total_comprado = 0
for compra in self.pays
total_comprado = total_comprado + compra.amount_total
self.computed_field = total_comprado
@vasanth, If I use @api.one means that I use one self record, isn't it? I want to use one record of self (sale.order) which has a collection of pays.
@zbik, I have the tab formatting correctly, when I do copy paste to the forum I do the mistake... in my .py file I have it correctly. Sorry!