[Trunk,6.1] Timezone ERROR in Scheduled Actions

Bug #1078200 reported by wowas
36
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Medium
OpenERP's Framework R&D

Bug Description

In module BASE in file "\base\ir\ir_cron.py" function _run_job don't work properly.

It take parametr "now" that calculated in local timezone like:

    now = datetime.now()

and then compared in loop with "numbercall" that take from DB in UTC:

    while nextcall < now and numbercall:
                ...
                if numbercall:
                    nextcall += _intervalTypes[job['interval_type']](job['interval_number'])

that cause "nextcall" calculated N times (N=TimeZoneShift/interval_number) and it make wrong interval between run actions.

For example:
========================================================================
current time = 09:00 (UTC)
local current time = 13:00 (TZ = UTC+4) (current time of server)
interval_number = 1 (from DB)
interval_type = minutes (from DB)
nextcall = 09:00 (from DB)
Time to run scheduled action, that cause run function _run_job that calculate new "nextcall":

    nextcall = 09:00 + 00:01 (and repeat it 240 times)

    nextcall = 13:01

So next run scheduled action will at 13:01 (UTC) or 17:01(local TZ). We have interval 4h and 1min, bat expect interval 1min!!!
========================================================================

For correct work need

    now = datetime.now()

change on

    now = datetime.utcnow()

wowas (wowas18)
description: updated
Revision history for this message
Arno Peters (awpeters) wrote :

The change described works.

Changed in openobject-server:
status: New → Confirmed
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Wowas ,

I have checked this issue with 6.1 as well as trunk but I did not get problem with cron.
python gives you "Local System Time" when you used now(), But in openerp ir_cron.py datetime.now() in utc time instead of
(UTC+5:30)(Asia/Culcutta).So it does't not make any difference with use of utcnow() or now()
in ir_cron.py and cron call sceduled action in every minutes.

I have attached video for you reference.

Thanks and waiting for reply.

Changed in openobject-server:
status: Confirmed → Incomplete
Revision history for this message
wowas (wowas18) wrote :

Problem occurs when the server run not in UTC zone. (System time not UTC).

Revision history for this message
wowas (wowas18) wrote :

If we use now(), then server must run in UTC zone.
If we use utcnow(), server may run in any zone.

It is sometimes inconvenient, if the real server is not located in Zero Time Zone, and can be used also for other purposes.

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello wowas ,

I agree with tat when real server is not located in UTC Zone,
there must be utcnow() instead of now().

Thanks.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Medium
status: Incomplete → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.