diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-05-31 14:37:38 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-05-31 14:37:38 +0200 |
| commit | cfe0523714b4244b080a268c0697f270f0b19e5b (patch) | |
| tree | ec6ea86aa32afd66ff4934ee5e745652777887a3 /addons/mail/wizard/mail_compose_message.py | |
| parent | e5b19bd5aa47fdb2da547cb75de9d33a20e1e180 (diff) | |
| parent | 8f21148e1a8eaae3bc09ec54377becb2361e7834 (diff) | |
[MERGE] forward port branch 12.0 up to 8f21148e1a8
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
| -rw-r--r-- | addons/mail/wizard/mail_compose_message.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 75b867d3ad5..95ae6372c41 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -372,7 +372,6 @@ class MailComposer(models.TransientModel): - normal mode: return rendered values /!\ for x2many field, this onchange return command instead of ids """ - attachment_ids = [] if template_id and composition_mode == 'mass_mail': template = self.env['mail.template'].browse(template_id) fields = ['subject', 'body_html', 'email_from', 'reply_to', 'mail_server_id'] @@ -388,6 +387,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 = { @@ -399,6 +399,8 @@ class MailComposer(models.TransientModel): 'type': 'binary', # override default_type from context, possibly meant for another model! } 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) @@ -411,8 +413,6 @@ class MailComposer(models.TransientModel): # this force the complete replacement of x2many field with # command and is compatible with onchange api.v7 values = self._convert_to_write(values) - if attachment_ids: - values.update(attachment_ids=[(6, 0, attachment_ids)]) return {'value': values} |
