Launchpad automatic translations update.
[odoo/odoo.git] / addons / auth_openid / res_users.py
index 3278184..9b02ce4 100644 (file)
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
+#    Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
@@ -18,6 +18,7 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
+from openerp.modules.registry import RegistryManager
 from openerp.osv import osv, fields
 import openerp.exceptions
 import tools
@@ -64,21 +65,22 @@ class res_users(osv.osv):
         if result:
             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))
+            with RegistryManager.get(db).cursor() as cr:
+                cr.execute("""UPDATE res_users
+                                SET login_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
 
-
     def check(self, db, uid, passwd):
         try:
             return super(res_users, self).check(db, uid, passwd)
         except openerp.exceptions.AccessDenied:
             if not passwd:
                 raise
-            with utils.cursor(db) as cr:
+            with RegistryManager.get(db).cursor() as cr:
                 cr.execute('''SELECT COUNT(1)
                                 FROM res_users
                                WHERE id=%s
@@ -92,3 +94,5 @@ class res_users(osv.osv):
 res_users()
 
 
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: