Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4520 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất


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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
4954
3
thg 7 20
11564
4
thg 10 24
5156
0
thg 11 16
3930
1
thg 12 24
936