In Sales Order, i created a custom email template and i need to attach images from the product.product to my custom email template. How do i add attachments in the mail (Send by Email)?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
1
Odpowiedz
2818
Widoki
Hi
You can create those files as ir. attachment records and update it to the attachment_ids of the mail template
Try this example
data_record = base64.b64encode(file)
ir_values = {
'name': 'Name of the Record',
'type': 'binary',
'datas': data_record,
'store_fname': data_record,
'mimetype': 'image/jpeg',
'res_model': 'product.product'
}
attachment = self.env['ir.attachment'].sudo().create(ir_values)
email_template = self.env.ref('module_name.mail_template', raise_if_not_found=False)
email_template.attachment_ids = [(4, attachment.id)]
email_template.sudo().send_mail(self.id)
email_template.attachment_ids = [(5, 0, 0)]
Attach a file in email template
Regards
from what model should i try this code? if i am creating a new template in sale.order, then i should add create a new function for this?
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
0
wrz 23
|
1707 | ||
|
0
wrz 23
|
1368 | ||
|
1
wrz 23
|
4010 | ||
|
1
maj 16
|
3579 | ||
|
2
cze 25
|
496 |