i want to export sale order to excel, but the date timezone is utc+0. my user is setted timezone to other.
how can i fix it?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
i want to export sale order to excel, but the date timezone is utc+0. my user is setted timezone to other.
how can i fix it?
Hi,
See a sample code for getting the current time as in users timezone.
# Import the packages
from datetime import datetime
import pytz
user = self.env['res.users'].browse(self.env.uid)
# converting time to users timezone
if user.tz:
tz = pytz.timezone(user.tz) or pytz.utc
time = pytz.utc.localize(datetime.now()).astimezone(tz)
else:
time = datetime.now()
Thanks
odoo 11
from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
from datetime import datetime, timedelta, date
start = (datetime.strptime(self.your_date_time_field, DEFAULT_SERVER_DATETIME_FORMAT) + timedelta(hours=7)).strftime('%d/%m/%Y %H:%M:%S')
If you do not use the export for a re-import, you can change the time in the Excel sheet.
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden