Community mailing list archives

community@mail.odoo.com

Re: ir_cron update nextcall timestamp error in winows odoo env, may be a bug of ir.cron

by
Leonardo Donelli
- 08/14/2015 06:58:28
The ``context_timestamp`` docstring says::

    :param datetime timestamp: naive datetime value (expressed in UTC)
to be converted to the client timezone

So calls to it should surely use ``.utcnow()``. You should open an
issue to Odoo on Github, or even better a pull request.

2015-08-14 10:17 GMT+02:00 wxyv <wxyv@sina.com>:
> Today, I found that after every ir.cron task executed, the timestamp
> nextcall will update to more 8 hours than correct timestamps. My time zone
> is asia shanghai, east 8 zone.
>
>
>
> I checked the code in ir_cron.py line 162:
>
>                 now = fields.datetime.context_timestamp(job_cr,
> job['user_id'], datetime.now())
>
> e.i: the local time is 2015-08-14 15:32:34.422988, then
>
> datetime.now() is same with local time, 2015-08-14 15:32:34.422988
>
>
>
> so, after context_timestamp with tz +8, the now is  2015-08-14
> 23:32:34.422988+08:00
>
>
>
> it is wrong!
>
>
>
> Then I do the same test on odoo linux env, it works well.
>
>
>
> At last, I just print datetime.now() in linux python interpret,  the result
> same with in windows.
>
>
>
> To resolve this problem, I change the datetime.now() to datetime.utcnow(),
> it works both windows and linux odoo!
>
>
>
> Is it a bug of ir.cron?
>
>
>
> Thanks
>
>
>
> Wade, Wang
>
>
>
> Shanghai, China
>
> Oscg
>
>
>
>
>
>
>
> _______________________________________________
> Mailing-List: https://www.odoo.com/groups/community-59
> Post to: mailto:community@mail.odoo.com
> Unsubscribe: https://www.odoo.com/groups?unsubscribe