Is there anyway to pay an invoice using the XML RPC such as with exec_workflow()?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
This is how I do it in Zato ESB using their integration with Odoo, you could take it as an example or a seudo-code but it's working ok and contains all the steps, obviously you need to adapt it because the following code is not complete:
You just need to change it to xmlrpclib if you use it, like this search example:invoice_pool = zoe.get_model('account.invoice')
voucher_pool = zoe.get_model('account.voucher')
journal_pool = zoe.get_model('account.journal')
partner_pool = zoe.get_model('res.partner')
invoice_info = invoice_pool.read([int(vals.get('id_invoice'))], ['partner_id', 'name', 'company_id', 'currency_id', 'type', 'state'])
if invoice_info:
invoice_info = invoice_info[0]
if invoice_info['state'] != 'open':
self.report_error("The invoice with code %s is not validated"% vals.get('id_invoice'))
return
else:
self.report_error("Invoice not found with id %s"% vals.get('id_invoice'))
return
partner_info = partner_pool.read([invoice_info['partner_id'][0]], ['is_company', 'parent_id'])[0]
while not partner_info['is_company'] and partner_info['parent_id']:
partner_info = partner_pool.read([invoice_info['parent_id'][0]], ['is_company', 'parent_id'])[0]
journal_id = journal_pool.search([('code', '=', vals.get('journal_code'))])
if not journal_id:
self.report_error("There is no journal asociated with this code: %s"%(vals.get('journal_code')))
return
result = voucher_pool.onchange_journal([],journal_id[0], [], False, partner_info['id'], False, float(vals.get('amount_payment')), 'receipt', invoice_info['company_id'][0], context={'invoice_id': invoice_info['id']})
voucher_vals = result['value']
voucher_vals.update({
'type': 'receipt',
'date': vals.get('fecha'),
'amount': float(vals.get('amount_payment')),
'partner_id': partner_info['id'],
'reference': invoice_info['name'],
'company_id': invoice_info['company_id'][0],
'journal_id': journal_id[0],
})
line_cr_ids = voucher_vals.pop('line_cr_ids')
voucher_vals['line_cr_ids'] = [(0,0,cr) for cr in line_cr_ids]
voucher_id = voucher_pool.create(voucher_vals)
ctx = {
'payment_expected_currency': invoice_info['currency_id'][0],
'close_after_process': True,
'invoice_type': invoice_info['type'],
'invoice_id': invoice_info['id'],
'type': 'receipt',
}
voucher_pool.button_proforma_voucher([voucher_id], context=ctx)
voucher_ids[invoice_info['id']] = voucher_id
Hope this helpsuid = oerp_common.authenticate(db, 'admin', password, {})
oerp_models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))ids = oerp_models.execute_kw(db, uid, password,'ir.module.module', 'search',[[['name', '=', module]]])s
Thanks. I'll give this methodology a try.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up