2
我正在学习开发OpenERP模块,我需要做的事情之一是计算用户输入的所有平均值。如何循环访问OpenERP中的字段值?
我的想法是循环记录,同时保持总和和计数,然后进行平均,但我似乎无法理解如何访问值的total
场的每个记录在sim.students
表
这里是我的代码
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
但印刷self.browse(cr,uid,id,['total'])
返回我browse_record(sim.student, 3)
,而不是总本身的结果的一部分。
我知道这一定很简单,但我似乎无法弄清楚如何达到这个价值。
任何提示赞赏
什么样的对象是自我? – Raufio 2013-02-13 01:09:01
是班学生(osv.osv)的一部分:'这有帮助吗? – JordanBelf 2013-02-13 01:12:31
是的。 self.browse(cr,uid,id).total做什么,如果有的话? – Raufio 2013-02-13 01:24:43