Hello, currently I am working on attendance module which in check am getting 5:30 extra time because it is in UTC format. I want this time in Ist timezone how can i fix this
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
To change the timezone of the attendance records in Odoo, you will need to do the following:
Set the correct timezone in the system configuration: Go to Settings > General Settings > Timezone and select the desired timezone (e.g., "Asia/Calcutta" for IST). This will ensure that the system uses the correct timezone for all date and time-related operations.
Convert the attendance records to the new timezone: If the attendance records are currently stored in a different timezone (e.g., UTC), you will need to convert them to the new timezone. You can do this using the following steps:
Create a new field to store the attendance time in the new timezone: Add a new field (e.g., "attendance_time_ist") to the hr.attendance model to store the attendance time in the new timezone.
Convert the attendance time to the new timezone: Use the localize() method of the pytz library to convert the attendance time to the new timezone. For example:
import pytz
# Convert attendance time from UTC to IST
attendance_time_utc = attendance.check_in
attendance_time_ist = pytz.utc.localize(attendance_time_utc).astimezone(pytz.timezone('Asia/Calcutta'))
# Update the attendance record with the new time
attendance.attendance_time_ist = attendance_time_ist
attendance.write({'attendance_time_ist': attendance_time_ist})
Update the attendance views to use the new field: Update the attendance views (e.g., the form view, list view, etc.) to use the new field (attendance_time_ist) instead of the old field (check_in).
I hope this helps! Let me know if you have any questions or need further assistance
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up