Odoo Help


Calculate fields from two different models

Arjun Khode
on 3/23/15, 1:46 AM 862 views

I have 'points' field in res.partner. I have 'total_amount' field in sale.order.

I want to calculate points from the amount sold. Like:


This should happen every time a sale is made. How to do this?

On 3/23/15, 4:05 AM

def _total_amount(self, cr, uid, ids, field_name, arg, context=None):

res = {}

partner_obj = self.pool.get('res.partner')

for value in self.browse(cr,uid,ids):

      amount+ = value.total_amount/10

return res

for line in partner_obj.browse(cr,uid,value.partner_id.id):


return res

'amount_sold' : fields.function(_total_amount, method=True, string='Amount Sold', type='float',),

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/23/15, 1:46 AM
Seen: 862 times
Last updated: 8/14/15, 1:11 AM