Skip to content

Commit

Permalink
[FIX] resource_booking: _get_calendar_context() with correct start / …
Browse files Browse the repository at this point in the history
…timezone
  • Loading branch information
norlinhenrik committed Feb 1, 2024
1 parent 813c223 commit 16abc45
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions resource_booking/models/resource_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import calendar
from datetime import datetime, timedelta
from datetime import timedelta

from dateutil.relativedelta import relativedelta

Expand Down Expand Up @@ -490,14 +490,18 @@ def _get_calendar_context(self, year=None, month=None, now=None):
:param datetime now: Represents the current datetime.
"""
month1 = relativedelta(months=1)
now = now or fields.Datetime.now()
now = fields.Datetime.context_timestamp(self, now or fields.Datetime.now())
year = year or now.year
month = month or now.month
start = datetime(year, month, 1)
start, now = (
fields.Datetime.context_timestamp(self, dt) for dt in (start, now)
start = now.replace(
year=year,
month=month,
day=1,
hour=0,
minute=0,
second=0,
microsecond=0,
)
start = start.replace(hour=0, minute=0, second=0, microsecond=0)
lang = self.env["res.lang"]._lang_get(self.env.lang or self.env.user.lang)
weekday_names = dict(lang.fields_get(["week_start"])["week_start"]["selection"])
booking_duration = timedelta(hours=self.duration)
Expand Down

0 comments on commit 16abc45

Please sign in to comment.