ValueError:SQL查询参数应该是元组,列表或字典

时间:2013-03-15 05:06:59

标签: python openerp

以正确的方式编辑代码。现在它正在运作。

这是我的代码:

def _random_letter(self, cr, uid, ids, name, args, context):
    num=[]
    for i in range(5):
        res = random.choice([1, 2, 3, 5, 9])
        num.append(res)
        print  (num)
        return num

def _mytest_query(self, cr, uid, ids, name, args, context):
    cr.execute("""update checkroll_plucker set worker_name =concat('worker','%s') where id='1'""", self._random_letter(cr, uid, ids, name, args, context))
    cr.commit()

另外,我仍然对要传递给函数的参数感到困惑。我浏览了一本开发人员的书,但没有明确的想法。我会提到下面的内容,如果纠正,请纠正我。

示例:

self, cr, uid, ids, name, args, context

self = call to current class of that method called 
cr = current row in the table 
uid = user id for check if he authorized or not for run this function 
name = column name we need to insert 
context = language/time details (but what is the use of it.more times it equals to None)

0 个答案:

没有答案