Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set timezone? #42

Closed
mrgaolei opened this issue Feb 14, 2017 · 10 comments
Closed

How to set timezone? #42

mrgaolei opened this issue Feb 14, 2017 · 10 comments

Comments

@mrgaolei
Copy link

I add that line:

odoo.env.context['tz'] = 'Asia/Shanghai'

But any datetime responses also UTC.

@dfang
Copy link

dfang commented Feb 22, 2017

odoo.env.user.tz = 'Asia/Shanghai'

@sebalix
Copy link
Contributor

sebalix commented Feb 22, 2017

You say that responses are UTC, what kind of RPC calls do you do?

@mrgaolei
Copy link
Author

@dfang thanks but response also UTC.

@mrgaolei
Copy link
Author

@sebalix I'm using odoorpc library and jsonrpc.
I say response are UTC because some record in database the are "2017-2-1 0:00:00", but when I set tz='Asia/Shanghai' it also "2017-2-1 0:00:00"

@sebalix
Copy link
Contributor

sebalix commented Feb 22, 2017

I mean, do you use odoo.env[MODEL].method(...) calls or odoo.execute(....)? The context is sent to the server only with the first one.

@mrgaolei
Copy link
Author

@sebalix
In Database sale.order has a row, id=1, date_order='2017-2-1 0:00:00'.

import odoorpc
odoo=odoorpc.ODOO()
odoo.login('odoo_v9', 'admin', 'password')
odoo.env.context['tz']='Asia/Shanghai'
S=odoo.env['sale.order']
S.browse(1)

response:

{
"xxxx": "xxxx",
"date_order": "2017-02-01 00:00:00"
}

But in Odoo web UI, it OK, shown as 2017-2-1 8:00:00.

@sebalix
Copy link
Contributor

sebalix commented Feb 22, 2017

Thanks for the example, I will try to figure out what is happening here.

@mrgaolei
Copy link
Author

@sebalix Can it be fixable?

@sebalix
Copy link
Contributor

sebalix commented Mar 17, 2017

I don't check yet. If you have time to do this, you could check the JSON value returned in your web browser when you navigate on the Odoo UI. If the raw value is not converted this means that it is the web client which convert it, not the server. This will help to do the right fix.

@sebalix
Copy link
Contributor

sebalix commented Oct 3, 2017

This issue was moved to OCA/odoorpc#8

@sebalix sebalix closed this as completed Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants