Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4562 มุมมอง

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?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด


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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to find the field type? แก้ไขแล้ว
1
มิ.ย. 25
5000
3
ก.ค. 20
11612
4
ต.ค. 24
5205
0
พ.ย. 16
3996
1
ธ.ค. 24
965