[MERGE] Properly record UTC login date, courtesy of Ian Beardslee

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

bzr revid: odo@openerp.com-20120331015143-46splgvkwl8n8r9j
This commit is contained in:
Olivier Dony
2012-03-31 03:51:43 +02:00
3 changed files with 13 additions and 7 deletions
+4 -2
View File
@@ -65,8 +65,10 @@ class res_users(osv.osv):
return result
else:
with utils.cursor(db) as cr:
cr.execute('UPDATE res_users SET date=now() WHERE login=%s AND openid_key=%s AND active=%s RETURNING id',
(tools.ustr(login), tools.ustr(password), True))
cr.execute("""UPDATE res_users
SET date=now() AT TIME ZONE 'UTC'
WHERE login=%s AND openid_key=%s AND active=%s RETURNING id""",
(tools.ustr(login), tools.ustr(password), True))
res = cr.fetchone()
cr.commit()
return res[0] if res else False
+5 -3
View File
@@ -211,9 +211,11 @@ class users(osv.osv):
encrypted_pw = encrypt_md5(password, salt)
# Check if the encrypted password matches against the one in the db.
cr.execute('UPDATE res_users SET date=now() ' \
'WHERE id=%s AND password=%s AND active RETURNING id',
(int(id), encrypted_pw.encode('utf-8')))
cr.execute("""UPDATE res_users
SET date=now() AT TIME ZONE 'UTC'
WHERE id=%s AND password=%s AND active
RETURNING id""",
(int(id), encrypted_pw.encode('utf-8')))
res = cr.fetchone()
cr.commit()
+4 -2
View File
@@ -256,8 +256,10 @@ class users(osv.osv):
user_id = ldap_obj.get_or_create_user(
cr, SUPERUSER_ID, conf, login, entry)
if user_id:
cr.execute('UPDATE res_users SET date=now() WHERE '
'login=%s', (tools.ustr(login),))
cr.execute("""UPDATE res_users
SET date=now() AT TIME ZONE 'UTC'
WHERE login=%s""",
(tools.ustr(login),))
cr.commit()
break
cr.close()