Skip to Content
Menu
This question has been flagged
2 Replies
3341 Views

Is there anyway to pay an invoice using the XML RPC such as with exec_workflow()?

Avatar
Discard
Dear ,

Thank you for emailing Cotton Babies. Our customer service system has received your email. Your ticket number is XQM-55694-261. Please reference this ticket number if you contact Cotton Babies about this issue.

If the issue you emailed about is time sensitive (address change, shipping upgrades, payment updates, order cancellations), please make note of the ticket number above and then give us a call at 1-888-332-2243.

Our customer service team is available to respond to customer messages on normal business days, 9am - 5pm CST.  We are occasionally closed for holidays.  Our goal is to respond to customer emails within one business day.

Just emailing for help with a return? Returns are easy! More information and instructions for processing a return can be found here:

http://www.cottonbabies.com/info.php#returns

Our Cloth Diapering Basics may have answers to many of your questions:
http://www.cottonbabies.com/clothdiapers.php

We know your time is extremely valuable, thank you for writing us, we will get back to you as soon as we possibly can.

Kindest regards,


Cotton Babies Customer Service Team
contactus@cottonbabies.com
1-888-332-2243
Best Answer

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:

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

You just need to change it to xmlrpclib if you use it, like this search example:

uid = 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

Hope this helps

Avatar
Discard
Author Best Answer

Thanks. I'll give this methodology a try.

Avatar
Discard