[FIX] auth_signup: fix wrong use of ir_model_data.get_object()
authorRaphael Collet <rco@openerp.com>
Thu, 23 Jan 2014 11:20:14 +0000 (12:20 +0100)
committerRaphael Collet <rco@openerp.com>
Thu, 23 Jan 2014 11:20:14 +0000 (12:20 +0100)
bzr revid: rco@openerp.com-20140123112014-0np3ayfhgk8nk5jv

addons/auth_signup/res_users.py

index 37ad9f6..3af5201 100644 (file)
@@ -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: