diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-06-06 11:54:35 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-06-06 11:54:35 +0200 |
| commit | 71a50a2214748fec413c5a0f042d0e7172ae6ea9 (patch) | |
| tree | 2e9ee11551350e23923390d9c53baf630b6ed834 /addons/mail/wizard/mail_compose_message.py | |
| parent | a7621137cb0d75ec545152d5e1d413c9d3548e45 (diff) | |
| parent | 409679866b2ee8352a8cb27460e7332563526924 (diff) | |
[MERGE] forward port branch saas-12.3 up to 409679866b2
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
| -rw-r--r-- | addons/mail/wizard/mail_compose_message.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index ba65f787257..def7b58033b 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -410,6 +410,7 @@ class MailComposer(models.TransientModel): values = self.generate_email_for_composer(template_id, [res_id])[res_id] # transform attachments into attachment_ids; not attached to the document because this will # be done further in the posting process, allowing to clean database if email not send + attachment_ids = [] Attachment = self.env['ir.attachment'] for attach_fname, attach_datas in values.pop('attachments', []): data_attach = { @@ -419,7 +420,9 @@ class MailComposer(models.TransientModel): 'res_id': 0, 'type': 'binary', # override default_type from context, possibly meant for another model! } - values.setdefault('attachment_ids', list()).append(Attachment.create(data_attach).id) + attachment_ids.append(Attachment.create(data_attach).id) + if values.get('attachment_ids', []) or attachment_ids: + values['attachment_ids'] = [(5,)] + values.get('attachment_ids', []) + attachment_ids else: default_values = self.with_context(default_composition_mode=composition_mode, default_model=model, default_res_id=res_id).default_get(['composition_mode', 'model', 'res_id', 'parent_id', 'partner_ids', 'subject', 'body', 'email_from', 'reply_to', 'attachment_ids', 'mail_server_id']) values = dict((key, default_values[key]) for key in ['subject', 'body', 'partner_ids', 'email_from', 'reply_to', 'attachment_ids', 'mail_server_id'] if key in default_values) |
