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

Hi,


We're creating sales order via RPC API which is working fine, now I want to convert those sales order to invoices also via API.

Is this possible and if yes how can this be accomplished ? 


Best Regards,

Avatar
Discard
Best Answer

Yes, it is possible to convert a sales order to an invoice using the RPC API in Odoo. To do this, you can use the action_invoice_create method on the sale.order model. This method will create an invoice for the sales order and return the id of the newly created invoice. Here is an example of how you can use this method:

# Rplac `sale_order_id` with the ID of the sales order you want to convert to an invoice
sale_order = sale_order_model.browse(sale_order_id)
invoice_id = sale_order.action_invoice_create()

Once you have the id of the newly created invoice, you can use the invoice_model to retrieve the invoice and make any necessary updates or modifications.

Note that this method will only create an invoice for the sales order. It will not validate or confirm the invoice. To do that, you will need to use the invoice_model.action_invoice_open method. For more information on the available methods and fields on the sale.order and account.invoice models, you can refer to the Odoo RPC API documentation.

Avatar
Discard
Best Answer

Configure and monitor the Odoo log file while you do anything via the User Interface to see the API methods called:

https://www.odoo.com/forum/help-1/how-can-i-see-which-api-calls-are-made-to-learn-what-odoo-is-doing-at-specific-times-183911

Avatar
Discard