Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3536 Widoki

Hello everybody,

im trying to implement a Calendar with public holidays in Odoo 12.

Wenn i add  dates via API like this

global_leave ={

"name": 'Bavaria', 

"date_from":'2019-01-01 00:00:00', 

"date_to":'2019-01-01 23:59:59,

 'calendar_id':month_id}

leave_id = od.SomethingAdd('resource.calendar.leaves', global_leave)

Odoo recieves the dates succesfully but The data is not displayed correctly

When i open "technical -> resource -> working time" and let me show the "global leaves" from one of these, i get

Start Date 01/01/2019 01:00:00
End Date 01/02/2019 00:59:59

how can i fix this?

thank you for help


Awatar
Odrzuć
Najlepsza odpowiedź

Odoo shows dates with timezone. 

In your database time is UTC+0 (if you haven't re-configured it). Thus, when you write to PostgreSQL using the API, you write date without any timezone. When you open a view time is shown according to your local timezone.

In order to fix it, you should substract the difference while making a request. Based on your examples, you should write time with an hour substracted. You can achieve that by converting your date strings into Python datetime and by using the Python timedelta. For more details regarding the Python datetime package have a look at this article - https://docs.python.org/3/library/datetime.html

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
maj 24
1950
2
kwi 23
2615
0
lut 21
1542
3
wrz 20
4054
1
mar 15
5209