我正在使用Odoo外部API (在python中: odoorpc)来促进客户应用程序(用于下单)和我的Odoo在线实例之间的通信。我目前无法使用XML RPC注册付款。
我已成功创建销售订单,可以为它们创建和验证发票。最后一步是注册付款(这完全是在Odoo之外处理的,所以我只是为了记账而注册它们),但我不能让它工作。
创建发票
x = odoo.execute_kw('sale.order', 'action_invoice_create', [[sales_order]], {'context': {'active_ids': sales_order}})[0]
验证发票
odoo.execute_kw('account.invoice', 'action_invoice_open', [[x]], {})
注册支付(我在另一个主题中找到了这个代码)
mod = odoo.env['account.payment']
id = mod.create({'amount': 32, 'payment_date': '2018-12-25 00:00:01', 'payment_type': 'inbound', 'payment_method_id': 2, 'journal_id': 8, 'currency_id': 1, 'partner_id': 853} )
mod.browse(id).invoice_ids = [x]
mod.browse(id).post()
注册付款第二次尝试:
odoo.execute_kw('account.payment', 'action_validate_invoice_payment', [[288],{
"active_id":x,
"active_ids":[x],
"active_model": "account.invoice",
"default_invoice_ids":[x],
"journal_type":"sale",
"search_disable_custom_filters": True,
"type": "out_invoice",
"tz": False
}])
我在注册付款的两次尝试中都遇到了这个错误。
RPCError:赋值前引用的局部变量“”sequence_code“”
发布于 2019-01-07 21:15:57
错误说明变量设置不正确:代码可以在here中找到
if rec.payment_type == 'transfer':
sequence_code = 'account.payment.transfer'
else:
if rec.partner_type == 'customer':
if rec.payment_type == 'inbound':
sequence_code = 'account.payment.customer.invoice'
if rec.payment_type == 'outbound':
sequence_code = 'account.payment.customer.refund'
if rec.partner_type == 'supplier':
if rec.payment_type == 'inbound':
sequence_code = 'account.payment.supplier.refund'
if rec.payment_type == 'outbound':
sequence_code = 'account.payment.supplier.invoice'
rec.name = self.env['ir.sequence'].with_context(ir_sequence_date=rec.payment_date).next_by_code(sequence_code)
rec
是您使用mod.create()
创建的payment,错误属于post()
的调用。您忘记了设置付款的partner_type
,在您的情况下应该是customer
。
也许会有更多的错误,但您的具体问题应该通过设置partner_type
来解决。
https://stackoverflow.com/questions/54065632
复制相似问题