Skip to Content
Menu
This question has been flagged
2 Replies
1510 Views

Hello,

I want to attach some documents from app documents to an email.

In the first step, i attach a binary file created with self.env['ir.attachment'].create() function. That's work.

Now i need to add one or many documents from app documents to this email to.

How can i do ?

I don't find the way to call my document and add to my mail. This document is not attach to the views i use to send the mail. it's a general rule that apply for all my records.

Thanks for your help

Eric

Avatar
Discard
Author Best Answer

I've sold by using a list for attachement and i add all attachment by extend this list.

That's work fine.

Avatar
Discard
Best Answer

Hi,

We can pass all the attachment through context.

ctx = {
  'default_model': 'sale.order',
  'default_res_id': self.ids[0],
  'default_use_template': bool(template.id),
  'default_template_id': template.id,
  'default_composition_mode': 'comment',
  'mark_so_as_sent': True,
  'custom_layout': "mail.mail_notification_paynow",
  'proforma': self.env.context.get('proforma', False),
  'force_email': True,
  'model_description': self.with_context(lang=lang).type_name,
  'default_attachment_ids': [(6, 0, self.designer_attachment_ids.ids)]
}
return {
  'type': 'ir.actions.act_window',
  'view_mode': 'form',
  'res_model': 'mail.compose.message',
  'views': [(False, 'form')],
  'view_id': False,
  'target': 'new',
  'context': ctx,
}

Regards

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 23
4985
0
Oct 24
99
2
Dec 22
3154
1
Dec 22
1625
2
Oct 24
2516