python字典更新元素_python-字典更新序列元素#0的长度为3; 2个为必填项

我想通过其他对象向对象account.bank.statement.line添加行,但出现以下错误:

“字典更新序列元素#0的长度为3;要求为2”

这是我的代码:

def action_account_line_create(self, cr, uid, ids):

res = False

cash_id = self.pool.get('account.bank.statement.line')

for exp in self.browse(cr, uid, ids):

company_id = exp.company_id.id

#statement_id = exp.statement_id.id

lines = []

for l in exp.line_ids:

lines.append((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

}))

inv_id = cash_id.create(cr, uid, lines,context=None)

res = inv_id

return res

我对此进行了更改,但随后遇到此错误:

File "C:\Program Files (x86)\OpenERP 6.1-20121029-003136\Server\server\.\openerp\workflow\wkf_expr.py", line 68, in execute

File "C:\Program Files (x86)\OpenERP 6.1-20121029-003136\Server\server\.\openerp\workflow\wkf_expr.py", line 58, in _eval_expr

File "C:\Program Files (x86)\OpenERP 6.1-20121029-003136\Server\server\.\openerp\tools\safe_eval.py", line 241, in safe_eval

File "C:\Program Files (x86)\OpenERP 6.1-20121029-003136\Server\server\.\openerp\tools\safe_eval.py", line 108, in test_expr

File "", line 0

^

SyntaxError: unexpected EOF while parsing

码:

def action_account_line_create(self, cr, uid, ids, context=None):

res = False

cash_id = self.pool.get('account.bank.statement.line')

for exp in self.browse(cr, uid, ids):

company_id = exp.company_id.id

lines = []

for l in exp.line_ids:

res = cash_id.create ( cr, uid, {

'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

}, context=None)

return res

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值