diff options
| author | Paramjit Singh Sahota <psa@tinyerp.com> | 2013-12-24 11:01:25 +0530 |
|---|---|---|
| committer | Paramjit Singh Sahota <psa@tinyerp.com> | 2013-12-24 11:01:25 +0530 |
| commit | 18d8368ee11eef0a74bacdb8f293414331bfa8da (patch) | |
| tree | fc21df70cbd2901396c2bcf2fee0b52d750abd43 /addons/mail/wizard/mail_compose_message.py | |
| parent | 5900672160c2bd5ae1d9257f20dbb5c51a193996 (diff) | |
| parent | 123185757f51ee7e146d7295864556999d2a6938 (diff) | |
[MERGE] Merged lp:~openerp-dev/openobject-addons/trunk-website-al
bzr revid: psa@tinyerp.com-20131224053125-3lrogsrgd3ccp0i6
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
| -rw-r--r-- | addons/mail/wizard/mail_compose_message.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index f129e5bf0f9..833811c07a1 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -19,7 +19,9 @@ # ############################################################################## +import base64 import re + from openerp import tools from openerp import SUPERUSER_ID from openerp.osv import osv @@ -260,6 +262,12 @@ class mail_compose_message(osv.TransientModel): for res_id, mail_values in all_mail_values.iteritems(): if mass_mail_mode and not wizard.post: + m2m_attachment_ids = self.pool['mail.thread']._message_preprocess_attachments( + cr, uid, mail_values.pop('attachments', []), + mail_values.pop('attachment_ids', []), + 'mail.message', 0, + context=context) + mail_values['attachment_ids'] = m2m_attachment_ids self.pool.get('mail.mail').create(cr, uid, mail_values, context=context) else: subtype = 'mail.mt_comment' @@ -298,7 +306,12 @@ class mail_compose_message(osv.TransientModel): if mass_mail_mode and wizard.model: email_dict = rendered_values[res_id] mail_values['partner_ids'] += email_dict.pop('partner_ids', []) - mail_values['attachments'] = email_dict.pop('attachments', []) + # process attachments: should not be encoded before being processed by message_post / mail_mail create + attachments = [] + if email_dict.get('attachments'): + for name, enc_cont in email_dict.pop('attachments'): + attachments.append((name, base64.b64decode(enc_cont))) + mail_values['attachments'] = attachments attachment_ids = [] for attach_id in mail_values.pop('attachment_ids'): new_attach_id = self.pool.get('ir.attachment').copy(cr, uid, attach_id, {'res_model': self._name, 'res_id': wizard.id}, context=context) |
