[FIX] res_users: improve behavior when user record is locked during login

Avoid logging an ugly and frightening traceback,
plus properly rollback the failed transaction before
continuing.
This is an extra fix for previous commit
rev. 4049 rev-id odo@openerp.com-20120213183207-45ptopqm0szritgx

lp bug: https://launchpad.net/bugs/713216 fixed

bzr revid: odo@openerp.com-20120822162921-i6zrik38w1czkamq
This commit is contained in:
Olivier Dony
2012-08-22 18:29:21 +02:00
parent a6214e81a8
commit fc8eeb7eb5
+4 -4
View File
@@ -490,7 +490,7 @@ class users(osv.osv):
cr.execute("""SELECT id from res_users
WHERE login=%s AND password=%s
AND active FOR UPDATE NOWAIT""",
(tools.ustr(login), tools.ustr(password)))
(tools.ustr(login), tools.ustr(password)), log_exceptions=False)
cr.execute("""UPDATE res_users
SET date = now() AT TIME ZONE 'UTC'
WHERE login=%s AND password=%s AND active
@@ -498,9 +498,9 @@ class users(osv.osv):
(tools.ustr(login), tools.ustr(password)))
except Exception:
# Failing to acquire the lock on the res_users row probably means
# another request is holding it. No big deal, we don't want to
# prevent/delay login in that case. It will also have been logged
# as a SQL error, if anyone cares.
# another request is holding it - no big deal, we skip the update
# for this time, and let the user login anyway.
cr.rollback()
cr.execute("""SELECT id from res_users
WHERE login=%s AND password=%s
AND active""",