Odoo Help

Welcome!

This community 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.

1

Calculate fields from two different models

By
Arjun Khode
on 3/23/15, 1:46 AM 565 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_customer.points+=total_amount/10

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

5

Vasanth

--Vasanth--
3458
| 5 3 8
Pondicherry, India
--Vasanth--
Vasanth
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):

   partner_obj.write(cr,uid,[value.partner_id.id],{'points':amount})

return res



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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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