From 86a7978d2d66b57ae118806a55e03e6111d5bccf Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 8 Mar 2012 16:56:50 +0100 Subject: [PATCH] [FIX] mail*: properly handle b64-encoding for attachments When reading the datas property of an attachment, a base64-encoded stream is expected. The mail.message.schedule_with_attach() method OTOH expects a binary file for attachments, so it should be decoded if extracted from a binary field. bzr revid: odo@openerp.com-20120308155650-blnwf7x2bkmsfue2 --- addons/mail/mail_message.py | 2 +- addons/mail/wizard/mail_compose_message.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index c103926bdac..d4ea41fedfe 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -263,7 +263,7 @@ class mail_message(osv.osv): attachment_data = { 'name': fname, 'datas_fname': fname, - 'datas': fcontent, + 'datas': fcontent and fcontent.encode('base64'), 'res_model': self._name, 'res_id': email_msg_id, } diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index e68bd70a739..af8baa314de 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -194,7 +194,7 @@ class mail_compose_message(osv.osv_memory): for mail in self.browse(cr, uid, ids, context=context): attachment = {} for attach in mail.attachment_ids: - attachment[attach.datas_fname] = attach.datas + attachment[attach.datas_fname] = attach.datas and attach.datas.decode('base64') references = None headers = {}