I created sale order in odoo 15:
custom_sale_order_id = models.execute_kw(db,uid, password,'sale.order', 'create',
[{
'company_id': int(custom_company_id),
'create_date': custom_actual_date,
'create_uid': custom_create_uid,
'currency_id': custom_currency_id,
'date_order': custom_actual_date,
'partner_id': custom_partner_id,
'payment_term_id': int(custom_payment_term_id),
'pricelist_id': int(custom_pricelist_id),
'team_id': int(custom_crm_team),
'state': custom_sale_order_state,
'invoice_status': custom_sale_order_invoice_status,
'warehouse_id': custom_warehouse_id,
}])
and
custom_sale_order_line_id = models.execute_kw(db,uid, password,'sale.order.line', 'create',
[{
'create_date': custom_actual_date,
'create_uid': custom_create_uid,
'currency_id': custom_currency_id,
'order_partner_id': custom_partner_id,
'product_id': custom_product_id,
'product_uom': int(custom_product_uom),
'product_uom_qty': custom_product_qty,
'qty_delivered': custom_product_qty,
'order_id': custom_sale_order_id,
'state': custom_sale_order_state,
'invoice_status': custom_sale_order_invoice_status,
}])
I’m struggling to automatically create the corresponding invoice to that sales order via xmlrpc. From sale order there is no method to create invoices.
There is 2 options to do it:
1) Call the same method that Odoo uses when you press the "Create Invoice" Button on and already created sales order. (Recommend)
2) Insert the data manually through the 'env' object in 'self' (You will have to do everything by your own throw a method in your model and call it from a button)
Happy to help :) an upvote will be awesome