← Back to team overview

openerp-india team mailing list archive

[Bug 1130812] [NEW] OpenERP Server not correctly forcing UTC (Ubuntu)

 

Public bug reported:

With OpenERP 6.1, the server should operate in UTC. In my understanding,
this means when I call

datetime.datetime.now() OR time it should give me a time in UTC. In all
of the OpenERP installations I have worked with, I am sorry to say it
does not work well with time. Some forms/views have the right time while
others do not. For instance, a new sale order will have the correct
time, but the picking will have a bogus time for field 'date' and
'date_done'.

Lets examine the code,

in stock.py addons 6.1 line 502, there is a default for field 'date'

'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),

If you print this date it is the customers current timezone NOT UTC time.
Continuing,

line 850:
'date_done': time.strftime('%Y-%m-%d %H:%M:%S')

This time is also the customers timezone. The effect is strange. The
time is stored in the database as the customers timezone, but the front
end forwards the time to UTC time, however since the time was already
delta the time is wrong. The time displayed is not the correct time. To
remedy this issue, I replaced all instances of

time with datetime.datetime.utcnow()

This stores the time correctly as UTC time, and the front end displays
the correct time. This is one example, The addons modules are littered
with instances of time or datetime.now(). IMO the implementation of UTC
time is not correct.

Additionally, the application needs to be able to detect when the time
is not calculated correctly and report this to the user, Especially in
cases of custom modules. The Server should also ensure the environment
is in UTC time, which clearly is not always the case.

** Affects: openobject-server
     Importance: Undecided
         Status: New

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

Title:
  OpenERP Server not correctly forcing UTC (Ubuntu)

Status in OpenERP Server:
  New

Bug description:
  With OpenERP 6.1, the server should operate in UTC. In my
  understanding, this means when I call

  datetime.datetime.now() OR time it should give me a time in UTC. In
  all of the OpenERP installations I have worked with, I am sorry to say
  it does not work well with time. Some forms/views have the right time
  while others do not. For instance, a new sale order will have the
  correct time, but the picking will have a bogus time for field 'date'
  and 'date_done'.

  Lets examine the code,

  in stock.py addons 6.1 line 502, there is a default for field 'date'

  'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),

  If you print this date it is the customers current timezone NOT UTC time.
  Continuing,

  line 850:
  'date_done': time.strftime('%Y-%m-%d %H:%M:%S')

  This time is also the customers timezone. The effect is strange. The
  time is stored in the database as the customers timezone, but the
  front end forwards the time to UTC time, however since the time was
  already delta the time is wrong. The time displayed is not the correct
  time. To remedy this issue, I replaced all instances of

  time with datetime.datetime.utcnow()

  This stores the time correctly as UTC time, and the front end displays
  the correct time. This is one example, The addons modules are littered
  with instances of time or datetime.now(). IMO the implementation of
  UTC time is not correct.

  Additionally, the application needs to be able to detect when the time
  is not calculated correctly and report this to the user, Especially in
  cases of custom modules. The Server should also ensure the environment
  is in UTC time, which clearly is not always the case.

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


Follow ups

References