Skip to Content
Menu
This question has been flagged
1 Reply
4869 Views

Using Odoo 15 and python xmlrpc for API

here is my problem: I have a created payment for which I store the id. Then, when i create the invoice that corresponds, I want to be able to add this specific outstanding credit of the customer through API just like this "Ajouter" (Add) button does. ("crédits en circulation" is outstanding credits):How would I do with python and xml-rpc tu simulate the use of this button for a specific payment (with its id)?

Note: For our sales workflow we have to create payments straight away and invoices later so I can't create the payment when creating the invoice


Avatar
Discard
Best Answer

Hello JohnPecno,

There is payment widget available to assign invoices with payment. pleae check below screenshot.




2) now we can debug python method while click on "ADD" button using network option of browser as below screenshot. "js_assign_outstanding_line" is method which link invice with payment.




I found test cases written in odoo to do this.

payment = self.env['account.payment'].create({
'date': time.strftime('%Y') + '-07-15',
'payment_type': 'inbound',
'payment_method_line_id': self.inbound_payment_method_line.id,
'partner_type': 'customer',
'partner_id': self.partner_agrolait_id,
'amount': 25,
'currency_id': self.currency_usd_id,
'journal_id': self.bank_journal_usd.id,
})
payment.action_post()

receivable_line = payment.line_ids.filtered('credit')
invoice.js_assign_outstanding_line(receivable_line.id)

as per above code you can pass payment line to "js_assign_outstanding_line" method for invoice recordset

hope this will help you to solve your issue

Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015
    

Avatar
Discard

Thanks CandidRoot .. your answer helped me more .
i want to add outstanding payment to invoice from payment through lines ('account.payment.invoice.line') model on payment but only one problem to send amount from lines to invoices .

i marked this as solution, thanks for helping.
the main method to assign invoice with payment is using js_assign_outstanding_line() and i can confirm the solution above is working for version 15.