From d6855c0bcb15b0d03039e24882348adee7014fe1 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 23 Jan 2014 12:20:14 +0100 Subject: [PATCH] [FIX] auth_signup: fix wrong use of ir_model_data.get_object() bzr revid: rco@openerp.com-20140123112014-0np3ayfhgk8nk5jv --- addons/auth_signup/res_users.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/auth_signup/res_users.py b/addons/auth_signup/res_users.py index 37ad9f68fe4..3af52017e05 100644 --- a/addons/auth_signup/res_users.py +++ b/addons/auth_signup/res_users.py @@ -262,9 +262,11 @@ class res_users(osv.Model): # send email to users with their signup url template = False if context.get('create_user'): - template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'set_password_email') - if not template.exists(): - template = False + try: + # get_object() raises ValueError if record does not exist + template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'set_password_email') + except ValueError: + pass if not bool(template): template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'reset_password_email') assert template._name == 'email.template' @@ -272,10 +274,7 @@ class res_users(osv.Model): for user in self.browse(cr, uid, ids, context): if not user.email: raise osv.except_osv(_("Cannot send email: user has no email address."), user.name) - try: - self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, force_send=True, raise_exception=True, context=context) - except Exception: - raise + self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, force_send=True, raise_exception=True, context=context) def create(self, cr, uid, values, context=None): if context is None: