From 7074f23e1edca5c3faad42397fea8142a63149b1 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Feb 2011 15:28:33 +0530 Subject: [PATCH] [FIX] email_template :- fix some problem. bzr revid: ysa@tinyerp.com-20110215095833-29l8h24iiqh9c29h --- addons/email_template/email_template.py | 22 +++++++++---------- addons/email_template/email_template_view.xml | 2 +- addons/emails/email_message.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index bde1aa01890..99b2be14923 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -66,7 +66,7 @@ class email_template(osv.osv): return {'value':{'model':mod_name}} _columns = { - 'name': fields.char('Name', size=250, required=True), + 'name': fields.char('Name', size=250), 'model_id':fields.many2one('ir.model', 'Resource'), 'model': fields.related('model_id', 'model', string='Model', type="char", size=128, store=True, readonly=True), 'track_campaign_item':fields.boolean('Resource Tracking', @@ -355,7 +355,7 @@ This is useful for CRM leads for example"), }) return {'value':result} - + def _generate_email(self, cr, uid, template_id, record_id, context=None): """ Generates an email from the template for @@ -372,7 +372,7 @@ This is useful for CRM leads for example"), smtp_server_id = template.smtp_server_id.id smtp_server = smtp_pool.browse(cr, uid, smtp_server_id, context=context) # determine name of sender, either it is specified in email_id - + email_id = smtp_server.email_id.strip() email_from = re.findall(r'([^ ,<@]+@[^> ,]+)', email_id)[0] if email_from != email_id: @@ -407,9 +407,9 @@ This is useful for CRM leads for example"), values['description'] += '\n\n' + sign #if values['body_html']: # values['body_html'] += sign - + attachment = [] - + # Add report as a Document if template.report_template: report_name = template.report_name @@ -428,19 +428,19 @@ This is useful for CRM leads for example"), report_name = reportname report_name = report_name + "." + format attachment.append((report_name, result)) - + # Add document attachments for attach in template.attachment_ids: #attach = attahcment_obj.browse(cr, uid, attachment_id, context) attachment.append((attach.datas_fname, attach.datas)) - + #Send emails context.update({'notemplate':True}) - email_id = email_message_pool.email_send(cr, uid, values.get('email_from'), values.get('email_to'), values.get('name'), values.get('description'), - model=model, email_cc=values.get('email_cc'), email_bcc=values.get('email_bcc'), reply_to=values.get('reply_to'), + email_id = email_message_pool.email_send(cr, uid, values.get('email_from'), values.get('email_to'), values.get('name'), values.get('description'), + model=model, email_cc=values.get('email_cc'), email_bcc=values.get('email_bcc'), reply_to=values.get('reply_to'), attach=attachment, message_id=values.get('message_id'), openobject_id=record_id, debug=True, subtype='plain', x_headers={}, priority='3', smtp_server_id=smtp_server.id, context=context) - email_message_pool.write(cr, uid, email_id, {'template_id': template.id}) + email_message_pool.write(cr, uid, email_id, {'template_id': context.get('template_id',template.id)}) return email_id @@ -484,7 +484,7 @@ class email_message(osv.osv): if template_ids and len(template_ids): template_id = template_ids[0] return template_pool.generate_email(cr, uid, [template_id], openobject_id, context=context) - return super(email_message, self).email_send(cr, uid, email_from, email_to, subject, body, model=model, email_cc=email_cc, email_bcc=email_bc, reply_to=reply_to, attach=attach, + return super(email_message, self).email_send(cr, uid, email_from, email_to, subject, body, model=model, email_cc=email_cc, email_bcc=email_bcc, reply_to=reply_to, attach=attach, message_id=message_id, openobject_id=openobject_id, debug=debug, subtype=subtype, x_headers=x_headers, priority=priority, smtp_server_id=smtp_server_id, context=context) email_message() diff --git a/addons/email_template/email_template_view.xml b/addons/email_template/email_template_view.xml index c486461ca9c..b74666c27c3 100644 --- a/addons/email_template/email_template_view.xml +++ b/addons/email_template/email_template_view.xml @@ -8,7 +8,7 @@ form
- + diff --git a/addons/emails/email_message.py b/addons/emails/email_message.py index 0b2c65ac8ef..77557738262 100644 --- a/addons/emails/email_message.py +++ b/addons/emails/email_message.py @@ -76,7 +76,7 @@ class email_message_template(osv.osv_memory): 'email_to': fields.char('To', help="Email Recipients", size=256), 'email_cc': fields.char('Cc', help="Carbon Copy Email Recipients", size=256), 'email_bcc': fields.char('Bcc', help='Blind Carbon Copy Email Recipients', size=256), - 'message_id': fields.char('Message Id', size=1024, help="Message Id on Email.", select=True), + 'message_id': fields.char('Message Id', size=1024, help="Message Id on Email.", select=1), 'references': fields.text('References', help="References emails."), 'reply_to':fields.char('Reply-To', size=250), 'sub_type': fields.char('Sub Type', size=32), @@ -255,7 +255,7 @@ class email_message(osv.osv): email_cc = [email_cc] if email_bcc and type(email_bcc) != list: email_bcc = [email_bcc] - + msg_vals = { 'name': subject, 'model': model or '',