出现此错误的原因是,您尝试
dict使用错误的序列(
list或
tuple)结构来更新对象。
cash_id.create(cr, uid, lines,context=None)试图转换
lines成字典对象:
(0, 0, { 'name': l.name, 'date': l.date, 'amount': l.amount, 'type': l.type, 'statement_id': exp.statement_id.id, 'account_id': l.account_id.id, 'account_analytic_id': l.analytic_account_id.id, 'ref': l.ref, 'note': l.note, 'company_id': l.company_id.id})从该元组中删除第二个零,以将其正确转换为dict对象。
要测试自己,请在python shell中尝试一下:
>>> l=[(0,0,{'h':88})]>>> a={}>>> a.update(l)Traceback (most recent call last): File "<pyshell#11>", line 1, in <module> a.update(l)ValueError: dictionary update sequence element #0 has length 3; 2 is required>>> l=[(0,{'h':88})]>>> a.update(l)


