我有一个功能:
def tong_thoigian (self,cr,uid,ids,context={}):
obj=self.browse(cr,uid,ids,context=context)[0]
cr.execute('''select name,giolam from x_giolam where name=%s'''%(obj.ma_luong))
kq=cr.fetchall()
tong=0.00000
for i in kq:
tong+=kq[1]
self.write(cr,uid,ids,{'tonggiolam':tong},context=context)
这是表 x_giolam:
class x_giolam(osv.osv):
_name = 'x_giolam'
_description = 'Gio Lam'
_columns = {
'name': fields.integer('Lọai',size=64,required="true"),
'giolam' : fields.float('Gio lam',size=64,required="True"),
'time_in': fields.char('Gio vào',size=20),
'time_out' :fields.char('Gio về',size=20),
'congviec' :fields.char('Cong viec',size=50),
}
x_giolam()
并且'self'是表x_salary,我认为说它并不重要,因为我想在表x_salary的name = Ma_luong时编写一个员工总工资的函数并且错误是
IndexError: list index out of range
Giolam 的类型是浮动的......我在 openerp 中写了,我认为 'tong+=kq[1]' 行中的错误我该如何解决?谢谢!!