Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
19098 Переглядів

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.  

Аватар
Відмінити
Найкраща відповідь

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 :(

did u configured, outgoing mail server?

Автор

it's good now :D thanks !

worked for me,thank you

Найкраща відповідь

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
бер. 15
8232
1
лип. 25
655
5
трав. 25
18075
0
квіт. 25
1036
1
квіт. 25
1505