Skip to content

Commit

Permalink
[FIX] resource_work_time_from_contracts: Make ORM accept UTC datetimes
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca authored and github-grap-bot committed Dec 19, 2023
1 parent 8f95380 commit 4503e9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions resource_work_time_from_contracts/tests/test_work_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

from datetime import date, timedelta, timezone

from odoo.addons.test_resource.tests.test_resource import datetime_str

from .test_work_time_base import TestWorkTimeBase


Expand Down
13 changes: 10 additions & 3 deletions resource_work_time_from_contracts/tests/test_work_time_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ def to_utc_datetime(self, year, month, day, *args, **kwargs):
"""
Create a UTC datetime from local time values
"""
return self.timezone.localize(
datetime.datetime(year, month, day, *args, **kwargs)
).astimezone(pytz.utc)
return (
self.timezone.localize(
datetime.datetime(year, month, day, *args, **kwargs)
).astimezone(pytz.utc)
# Odoo's ORM refuses to work with datetime objects that have tzinfo
# set. Unset it here instead of doing it manually every time. The
# tzinfo is implicit as a result of this function's name being
# 'to_utc_datetime'.
.replace(tzinfo=None)
)

0 comments on commit 4503e9f

Please sign in to comment.