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

I am learning to develop OpenERP modules, and one of the things I need to do is calculate the average of all the inputs from the user.

My idea was to loop the records while keeping the sum and the count and then make the average, but I can't seem to understand how to access the value for the total field for each record in the sim.students table

Here is part of my code

def get_text(self, cr, uid, ids, fields, arg, context):
    result = {}
    i = 0
    for id in ids:
        print self.browse(cr,uid,id,['total'])
        print id
        i = i+1
        print i

    return result

But the result of printing self.browse(cr,uid,id,['total']) returns me browse_record(sim.student, 3) and not the total itself.

I know this must be really simple but I can't seem to figure out how to get to that value.

Any tip much appreciated

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

You need to change it to

print self.browse(cr,uid,id).total

self.browse returns a browsable object, and then you can access it's fields...

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 23
423
2
พ.ค. 25
1223
0
มี.ค. 24
1222
0
พ.ค. 20
2568
3
ธ.ค. 19
4726