I'm using the Odoo External API (in python: odoorpc) to facilitate communication between a customer app (used to place orders) and my Odoo Online instance. I'm currently not able to register a payment using XML RPC.
I have successfully created sales orders and I can create and validate invoices for them. The last step is to register a payment (which are handled completely outside of Odoo, so I just have to register them for accounting purposes), but I can't get it to work.
create invoice
x = odoo.execute_kw('sale.order', 'action_invoice_create', [[sales_order]], {'context': {'active_ids': sales_order}})[0]
validate invoice
odoo.execute_kw('account.invoice', 'action_invoice_open', [[x]], {})
register payment (i found this code in another topic)
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()
register payment second attempt:
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
}])
I'm getting this error on both attempts to register my payment.
RPCError: local variable 'sequence_code' referenced before assignment