Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Send email with python

Coralie Cardon
on 2/2/16, 8:47 AM 668 views


I would like send an email with python,

I try to complete the table named mail.compose.message.res.partner.rel

But it's Many2many relation.

How can i do ?

I try this :

mail_rel = self.env['mail.compose.message.res.partner.rel']

mail_values_rel = {

'wizard_id': mail.id,

'partner_id': '8' ,


mail_mail_obj_rel = mail_rel.create(mail_values_rel)

But my partner_ids isn't fixed. Idon't know how i can have his id.  



| 4 3 5
Hyderabad, India

On 2/3/16, 12:25 AM


For send a mail through code,

First you need to create a new record for "mail.mail" object with your respective values like:

mail_pool = self.env['mail.mail']


values.update({'subject': 'Your subject'})

values.update({'email_to': 'To email'})

values.update({'body_html': 'body' })

values.update({'body': 'body' })

values.update({'res_id': 'obj.id' }) #[optional] here is the record id, where you want to post that email after sending

values.update({'model': ''Object Name }) #[optional] here is the object(like 'project.project')  to whose record id you want to post that email after sending

msg_id = mail_pool.create(values)

# And then call send function of the mail.mail,

if msg_id:


Hope it Helps you

ok i do this but i don't receive email :(

BHC SPRL, Coralie Cardon
on 2/3/16, 2:44 AM

did u configured, outgoing mail server?

on 2/4/16, 1:05 AM

it's good now :D thanks !

BHC SPRL, Coralie Cardon
on 2/4/16, 4:40 AM

Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/4/16, 4:22 AM

You could use the method described here to do the same using the email.template model


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 2/2/16, 8:47 AM
Seen: 668 times
Last updated: 2/4/16, 4:22 AM