Odoo Help

0

Send email with python

By
Coralie Cardon
on 2/2/16, 8:47 AM 941 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

--Pawan--
1392
| 4 4 5
Hyderabad, India
--Pawan--


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

--Axel Mendoza--
10768
| 7 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

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: 941 times
Last updated: 2/4/16, 4:22 AM