diff options
| author | Yogesh (OpenERP) <ysa@tinyerp.com> | 2011-02-08 17:48:55 +0530 |
|---|---|---|
| committer | Yogesh (OpenERP) <ysa@tinyerp.com> | 2011-02-08 17:48:55 +0530 |
| commit | 20b34865ea97b88fbaf867ab90fbb9f48ef124ef (patch) | |
| tree | 71883425de01ad6bc63ea12f0d97a67b1af1c10d | |
| parent | 5043a89b66a3152e412a6a8efdd0d37571cec276 (diff) | |
Fix problem in email.template.preview wizard.
bzr revid: ysa@tinyerp.com-20110208121855-zxqrmgyk0rkhlms9
| -rw-r--r-- | addons/email_template/__init__.py | 5 | ||||
| -rw-r--r-- | addons/email_template/email_template.py | 5 | ||||
| -rw-r--r-- | addons/email_template/wizard/email_template_preview.py | 15 |
3 files changed, 9 insertions, 16 deletions
diff --git a/addons/email_template/__init__.py b/addons/email_template/__init__.py index dec5a285362..15a99722203 100644 --- a/addons/email_template/__init__.py +++ b/addons/email_template/__init__.py @@ -23,10 +23,5 @@ import email_template import wizard -try: - from mako.template import Template as MakoTemplate -except ImportError: - logging.getLogger('init').warning("module email_template: Mako templates not installed") - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 65f52e68341..cad467a37f9 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -31,6 +31,11 @@ from tools.translate import _ import tools import pooler +try: + from mako.template import Template as MakoTemplate +except ImportError: + logging.getLogger('init').warning("module email_template: Mako templates not installed") + def get_value(cursor, user, recid, message=None, template=None, context=None): """ Evaluates an expression and returns its value diff --git a/addons/email_template/wizard/email_template_preview.py b/addons/email_template/wizard/email_template_preview.py index 21c429574cd..98608f469ee 100644 --- a/addons/email_template/wizard/email_template_preview.py +++ b/addons/email_template/wizard/email_template_preview.py @@ -36,13 +36,12 @@ class email_template_preview(osv.osv_memory): #Fills up the selection box which allows records from the selected object to be displayed self.context = context if 'template_id' in context: - ref_obj_id = self.pool.get('email.template').read(cr, uid, context['template_id'], ['object_name'], context) - ref_obj_name = self.pool.get('ir.model').read(cr, uid, ref_obj_id['object_name'][0], ['model'], context)['model'] + ref_obj_id = self.pool.get('email.template').browse(cr, uid, context['template_id'], context).object_name.id + ref_obj_name = self.pool.get('ir.model').browse(cr, uid, ref_obj_id, context).model model_obj = self.pool.get(ref_obj_name) ref_obj_ids = model_obj.search(cr, uid, [], 0, 20, 'id', context=context) if not ref_obj_ids: ref_obj_ids = [] - # also add the default one if requested, otherwise it won't be available for selection: default_id = context.get('default_rel_model_ref') if default_id and default_id not in ref_obj_ids: @@ -54,8 +53,7 @@ class email_template_preview(osv.osv_memory): if context is None: context = {} result = super(email_template_preview, self).default_get(cr, uid, fields, context=context) - if (not fields or 'rel_model_ref' in fields) and 'template_id' in context \ - and not result.get('rel_model_ref'): + if (not fields or 'rel_model_ref' in fields) and 'template_id' in context and not result.get('rel_model_ref'): selectables = self._get_model_recs(cr, uid, context=context) result['rel_model_ref'] = selectables and selectables[0][0] or False return result @@ -67,12 +65,7 @@ class email_template_preview(osv.osv_memory): @param user: ID of current user @param context: OpenERP Context """ - return self.pool.get('email.template').read( - cursor, - user, - context['template_id'], - ['object_name'], - context).get('object_name', False) + return self.pool.get('email.template').read(cursor, user, context['template_id'], ['object_name'], context).get('object_name', False) _columns = { 'ref_template':fields.many2one( |
