Actually the database stores the Datetime
field according to the system timezone. In Odoo, views which will be automatically converted according to the user's timezone if it is set.
On your images, I can see the time difference id +5:30 ie, Asia/Kolakata timezone. So your custom operations on Datetime
field need the proper conversion of Timezone according to the user.
Odoo views and ORM methods are treated the tz
with moment.js
and the pytz
conversions. This is actually a good feature to manage different timezones in Odoo.
You can use astimezone
on Datetime
objects:
def astimezone(self, tz): # known case of datetime.datetime.astimezone
""" tz -> convert to local time in new timezone tz """
return datetime(1, 1, 1)
or
fields.Datetime.context_timestamp(self, datetime.strptime(value, DEFAULT_SERVER_DATETIME_FORMAT))