Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
4605 Visninger

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?

Avatar
Kassér
Bedste svar


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',),

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
jun. 25
5054
3
jul. 20
11685
4
okt. 24
5239
0
nov. 16
4044
1
dec. 24
1004