Odoo Help

0

Send email with python

By
Coralie Cardon
on 2/2/16, 8:47 AM 1,348 views

Hello, 

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.  

1
Pawan
On 2/3/16, 12:25 AM

coco,

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={}

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:

mail_pool.send([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?

Pawan
on 2/4/16, 1:05 AM

it's good now :D thanks !

BHC SPRL, Coralie Cardon
on 2/4/16, 4:40 AM
0
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

https://www.odoo.com/forum/help-1/question/correct-way-to-e-mail-custom-html-record-in-function-96570#answer_97108

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

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