As i am new to the odoo i need some help. i want to sent my created invoice to the coustomer email using external api. here is my code how i am creating the invoice
import xmlrpc.client
# Odoo API information
url = ''
db = ''
username = ''
password = ''
# Connect to Odoo API
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
# Create a connection object
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
customer_id=10
product_id=1
# Create an invoice
invoice_data = {
'partner_id': customer_id, # ID of the customer for whom you want to create the invoice
'move_type': 'out_invoice', # Invoice type (out_invoice for customer invoice)
# Add other invoice data like invoice line items, payment terms, etc.
# For example:
'invoice_line_ids': [
(0, 0, {
'product_id': product_id, # ID of the product on the invoice line
'quantity': 2,
'price_unit': 100.0,
})
],
}
invoice_id = models.execute_kw(db, uid, password, 'account.move', 'create', [invoice_data])
# Send the invoice by email
models.execute_kw(db, uid, password, 'account.move', 'action_post', [invoice_id])
invoice_sent = models.execute_kw(db, uid, password, 'account.move', 'action_invoice_sent', [invoice_id])
i am using odoo online. kindly help.