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

Hello, i'm trying to send email of an invoice in python but i have some problems...

First, i have already created an invoice and confirmed it.
After i try to send it using account invoice send like that but got an error :
Code : models.execute_kw(db, uid, password, 'account.invoice.send' 'send_and_print_action', [[mail_id]],{})
Error :​  Fault 2 Record deleted or record not exist

So i tried to create a ''account.invoice.send' but got an error too :
Code : models.execute_kw(db, uid, password, 'account.invoice.send', 'create', [
{'res_id': invoice[0]['id'],
'is_email': True,
'invoice_without_email': False,
'is_print': False,
'printed': False,
'move_types': False,
'invoice_ids': [(34, 0, vals)],
'partner_ids': invoice[0]['partner_id'],
'composition_mode': "comment",
'template_id': mail_template,
'subject': invoice[0]["company_id"][1] + " - Facture",
'attachment_ids': invoice[0]["attachment_ids"]
}])
Error : Fault 2 You can only send invoices


Thank your for your help ! 

Avatar
Discard
Best Answer

Hello Thomas,

To send an email of an invoice in Odoo using Python, you can try the following code.

:

In this code, you first authenticate with the Odoo server using your credentials. Then, you search for the ID of the email template you want to use to send the invoice. Next, you search for the ID of the invoice you want to send and retrieve its partner ID. Finally, you use the message_post method of the account.invoice model to send the invoice email, passing in the necessary parameters such as the partner ID, the email template ID, and the email sender address.

Regards,

Ksolves Team!

Avatar
Discard