From d22c3043aa595db7137f9903791baae1e4f57853 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 12 Sep 2011 20:00:25 +0200 Subject: [PATCH] [FIX] marketing_campaign: typos and cleanup bzr revid: odo@openerp.com-20110912180025-scdjvcnquo07zcha --- addons/email_template/email_template.py | 10 ++--- addons/email_template/email_template_view.xml | 4 +- .../wizard/email_template_preview.py | 19 ++++------ .../wizard/email_template_preview_view.xml | 37 +++++++++++-------- .../marketing_campaign/marketing_campaign.py | 11 +----- 5 files changed, 37 insertions(+), 44 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 6fbd13a9599..3917b3f2ddb 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -360,18 +360,18 @@ class email_template(osv.osv): and schedule it for delivery through the ``mail`` module's scheduler. :param int template_id: id of the template to render - :param int record_id: id of the record to render the template with - (model is taken from the template) + :param int res_id: id of the record to render the template with + (model is taken from the template) """ mail_message = self.pool.get('mail.message') ir_attachment = self.pool.get('ir.attachment') template = self.browse(cr, uid, template_id, context) values = self.generate_email(cr, uid, template_id, res_id, context=context) - attachments = values.pop('attachments') - message_id = mail_message.create(values) + attachments = values.pop('attachments') or {} + message_id = mail_message.create(cr, uid, values, context=context) # link attachments attachment_ids = [] - for fname, fcontent in values['attachments'].iteritems(): + for fname, fcontent in attachments.iteritems(): attachment_data = { 'name': fname, 'datas_fname': fname, diff --git a/addons/email_template/email_template_view.xml b/addons/email_template/email_template_view.xml index fe460d8829d..b4f76a03c6c 100644 --- a/addons/email_template/email_template_view.xml +++ b/addons/email_template/email_template_view.xml @@ -31,10 +31,10 @@ - + - + diff --git a/addons/email_template/wizard/email_template_preview.py b/addons/email_template/wizard/email_template_preview.py index 7d316da8626..650b714866d 100644 --- a/addons/email_template/wizard/email_template_preview.py +++ b/addons/email_template/wizard/email_template_preview.py @@ -57,11 +57,11 @@ class email_template_preview(osv.osv_memory): result = super(email_template_preview, self).default_get(cr, uid, fields, context=context) email_template = self.pool.get('email.template') - template_id = context.get('active_id', False) - if 'res_id' in fields: + template_id = context.get('template_id') + if 'res_id' in fields and not result.get('res_id'): records = self._get_records(cr, uid, context=context) result['res_id'] = records and records[0][0] or False # select first record as a Default - if template_id and 'model_id' in fields: + if template_id and 'model_id' in fields and not result.get('model_id'): result['model_id'] = email_template.read(cr, uid, int(template_id), ['model_id'], context).get('model_id', False) return result @@ -69,18 +69,13 @@ class email_template_preview(osv.osv_memory): 'res_id':fields.selection(_get_records, 'Sample Document'), } - def on_change_ref(self, cr, uid, ids, res_id, context=None): - if context is None: - context = {} + def on_change_res_id(self, cr, uid, ids, res_id, context=None): if not res_id: return {} vals = {} - if context == {}: - context = self.context - - template_pool = self.pool.get('email.template') - template_id = context.get('template_id', False) - template = template_pool.get_email_template(cr, uid, template_id=template_id, record_id=res_id, context=context) + email_template = self.pool.get('email.template') + template_id = context and context.get('template_id') + template = email_template.get_email_template(cr, uid, template_id=template_id, record_id=res_id, context=context) model = template.model vals['email_to'] = self.render_template(cr, uid, template.email_to, model, res_id, context) vals['email_cc'] = self.render_template(cr, uid, template.email_cc, model, res_id, context) diff --git a/addons/email_template/wizard/email_template_preview_view.xml b/addons/email_template/wizard/email_template_preview_view.xml index 80d3e558ef4..4aab57396ad 100644 --- a/addons/email_template/wizard/email_template_preview_view.xml +++ b/addons/email_template/wizard/email_template_preview_view.xml @@ -8,26 +8,31 @@ form
- - - - - + + + - - - - + + + + - - - - - + + + + + + + + + + + + +