From 487d6e924e4f8c6f89343bf98a3f8ff4ce1c4ee4 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 28 Oct 2009 11:55:21 +0530 Subject: [PATCH] [IMP]: CRM Ergonomy Improvement blueprint: Added fields.binary in send mail wizard of crm to put attachements to emails. bzr revid: rpa@tinyerp.com-20091028062521-3wqo97t8olfdgn48 --- .../crm/wizard/wizard_crm_new_send_email.py | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/addons/crm/wizard/wizard_crm_new_send_email.py b/addons/crm/wizard/wizard_crm_new_send_email.py index b905d31aa8e..9cb3d87466c 100644 --- a/addons/crm/wizard/wizard_crm_new_send_email.py +++ b/addons/crm/wizard/wizard_crm_new_send_email.py @@ -28,7 +28,7 @@ import ir import pooler import tools from tools.translate import _ - +import base64 email_send_form = '''
@@ -39,17 +39,30 @@ email_send_form = ''' + + + + + + ''' email_send_fields = { 'to': {'string':"To", 'type':'char', 'size':64, 'required':True}, 'cc': {'string':"CC", 'type':'char', 'size':128,}, 'subject': {'string':'Subject', 'type':'char', 'size':128, 'required':True}, - 'text': {'string':'Message', 'type':'text_tag', 'required':True} + 'text': {'string':'Message', 'type':'text_tag', 'required':True}, + 'doc1' : {'string':"Attachment1", 'type':'binary'}, + 'doc2' : {'string':"Attachment2", 'type':'binary'}, + 'doc3' : {'string':"Attachment3", 'type':'binary'}, } # this sends an email to ALL the addresses of the selected partners. def _mass_mail_send(self, cr, uid, data, context): + + attach = filter(lambda x: x, [data['form']['doc1'], data['form']['doc2'], data['form']['doc3']]) + attach = map(lambda x: x and ('Attachment'+str(attach.index(x)+1), base64.decodestring(x)), attach) + pool = pooler.get_pool(cr.dbname) case_pool=pool.get('crm.case') @@ -64,14 +77,19 @@ def _mass_mail_send(self, cr, uid, data, context): body = data['form']['text'] if case.user_id.signature: body += '\n\n%s' % (case.user_id.signature) - tools.email_send( + flag = tools.email_send( case.user_id.address_id.email, emails, data['form']['subject'], - case_pool.format_body(body), + body, + attach=attach, reply_to=case.section_id.reply_to, tinycrm=str(case.id) ) + if flag: + raise wizard.except_wizard(_('Message!'),("Email Successfully Sent..!!")) + else: + raise wizard.except_wizard(_('Warning!'),("Email is not sent Successfully")) return {} def _get_info(self, cr, uid, data, context):