← Back to team overview

openerp-india team mailing list archive

[Bug 967829] Re: Login Date Incorrect

 

** Project changed: openobject-server => openobject-addons

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/967829

Title:
  Login Date Incorrect

Status in OpenERP Addons (modules):
  New

Bug description:
  I noticed that the login date for LDAP users was in the future (I'm in
  Pacific/Auckland or GMT+13), yet the Administrator user was correct.

  It seems that although the addons/base/res/res_users.py updates the
  login date and time (res_users.date) using UTC, the various other
  methods just set res_users.date use the now() function. The now()
  function takes the timezone of the server without consideration to the
  timezone of the user.  The code within OpenERP applies timezone
  formating to the information returned from the database.

  ### addons/base/res/res_users.py

   cr.execute("""UPDATE res_users
                 SET date = now() AT TIME ZONE 'UTC'
                 WHERE login=%s AND password=%s AND active
                 RETURNING id""",
             (tools.ustr(login), tools.ustr(password)))

  I found the other places by using "grep -Ri 'update res_users' *"

  ### addons/auth_openid/res_users.py

   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))

  ### addons/base_crypt/crypt.py

   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')))

  ### addons/users_ldap/users_ldap.py

    cr.execute('UPDATE res_users SET date=now() WHERE '
               'login=%s', (tools.ustr(login),))

  The 3 "SET date=now()" need to be changed to "SET date=now() AT TIME
  ZONE 'UTC'" as per addons/base/res/res_users.py, and in my example
  changes below formatted to the same as the
  addons/base/res/res_users.py

  ### addons/auth_openid/res_users.py

   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))

  ### addons/base_crypt/crypt.py

   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')))

  ### addons/users_ldap/users_ldap.py

    cr.execute("""UPDATE res_users
                  SET date=now() AT TIME ZONE 'UTC'
                  WHERE login=%s""",
              (tools.ustr(login),))

  Because I use the users_ldap module, I have only tested changes to
  that module, and they appear to be correct.

  This bug could also be linked to some of the other issues around how
  dates are updated and retrieved from the database and displayed in the
  interface and reports.

  If, as in addons/base/res/res_users.py, dates and times are used as
  UTC with the interface making adjustments for language and timezone it
  should be consistent throughout the rest of the application.  Using
  'timestamp without time zone' consistently as the database type for
  dates and times makes it easy for developers and users to know that
  they need to treat timestamps in the database as UTC, and the
  module/report/UI being created needs to treat the date and time as
  such.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/967829/+subscriptions


References