Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
1794 มุมมอง

I have a code that search for attendance record

att_var1 = att_obj.search([
('employee_id', '=', get_user_id.id),
('check_in', '>=',check_in_date.strftime('%Y-%m-%d 00:00:00')),
('check_in', '])

Here check_in_date is a date field im adding min and max time using strftime now the results will be get for a day start to end.

But when this code executes the min time is modified based on UTC. i,e) min time is +5:30, our timezone is Asia/Kolkata and max time is also +5:30 so instead of getting a day record it fetches today 5:30 AM to tomorrow 5:30 AM


Does anyone have any knowledge about how to rectify this


i want to get data based on 00:00 to 23:59


Thanks in Advance



อวตาร
ละทิ้ง
ผู้เขียน

Does anyone knows how odoo converts user timezone into UTC in user defined filters

คำตอบที่ดีที่สุด

Hi,

Use the fields.Datetime.context_timestamp(record, timestamp) method. This method returns the provided timestamp converted to the client's timezone.


Hope it helps

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

See https://www.odoo.com/documentation/17.0/developer/reference/backend/orm.html?highlight=utc#odoo.fields.Datetime.context_timestamp

static context_timestamp(record, timestamp)
Return the given timestamp converted to the client’s timezone.
อวตาร
ละทิ้ง

And how to use this in search view filter ?

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 25
3202
1
ม.ค. 24
1456
0
เม.ย. 15
4536
1
ธ.ค. 23
1807
1
ก.พ. 22
4576