i have fields.datetime when i input manual and press enter then time auto +7h but i select time on picker datetime then not +7h. Please help me fix it.
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
i have fields.datetime when i input manual and press enter then time auto +7h but i select time on picker datetime then not +7h. Please help me fix it.
Thanks
Hi,
It depends on the user's preferred TimeZone. Ensure that the user's timezone is correctly set by going to Settings > Users & Companies > Users, selecting the user, and checking the "Timezone" field under the Preferences page.

You have to use ORM methods to convert the datetime data to a different timezone (TZ).
import pytz
from datetime import datetime
from odoo import fields
# Ensure you have the user's timezone set
user_tz = self.env.user.tz or 'UTC'
local_tz = pytz.timezone(user_tz)
# Convert datetime from string to UTC timezone
utc_dt = pytz.utc.localize(datetime.strptime(your_date_or_datetime_info, fields.Datetime.DEFAULT_SERVER_DATETIME_FORMAT))
# Convert UTC datetime to user's local timezone
date_field = utc_dt.astimezone(local_tz).strftime("%d/%m/%Y %H:%M:%S")
Hope it helps
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.