0

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

这是我的代码:

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)
4

0 回答 0