diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index f9e3ff52f28..d7d5ae9bae1 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -19,6 +19,7 @@ # ############################################################################## +import base64 import re from openerp import tools @@ -261,7 +262,6 @@ class mail_compose_message(osv.TransientModel): for res_id, mail_values in all_mail_values.iteritems(): if mass_mail_mode and not wizard.post: - # process attachments and attachment_ids before sending values to mail_mail.Lcreat m2m_attachment_ids = self.pool['mail.thread']._message_preprocess_attachments( cr, uid, mail_values.pop('attachments', []), mail_values.pop('attachment_ids', []), @@ -306,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 and attachment_ids before sending values to 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)