[FIX] auth_signup: duplicated login must not generate 500 errors
authorChristophe Simonis <chs@openerp.com>
Tue, 18 Feb 2014 12:17:26 +0000 (13:17 +0100)
committerChristophe Simonis <chs@openerp.com>
Tue, 18 Feb 2014 12:17:26 +0000 (13:17 +0100)
bzr revid: chs@openerp.com-20140218121726-sm266vfhe44qsfro

addons/auth_signup/res_users.py

index 3af5201..aaab742 100644 (file)
@@ -25,7 +25,7 @@ from urlparse import urljoin
 
 from openerp.addons.base.ir.ir_mail_server import MailDeliveryException
 from openerp.osv import osv, fields
-from openerp.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
+from openerp.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT, ustr
 from ast import literal_eval
 from openerp.tools.translate import _
 
@@ -236,7 +236,11 @@ class res_users(osv.Model):
         # create a copy of the template user (attached to a specific partner_id if given)
         values['active'] = True
         context = dict(context or {}, no_reset_password=True)
-        return self.copy(cr, uid, template_user_id, values, context=context)
+        try:
+            return self.copy(cr, uid, template_user_id, values, context=context)
+        except Exception, e:
+            # copy may failed if asked login is not available.
+            raise SignupError(ustr(e))
 
     def reset_password(self, cr, uid, login, context=None):
         """ retrieve the user corresponding to login (login or email),