Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions hr_shift/models/shift_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,12 @@ def _compute_display_name(self):
line.display_name = (
f"{_(dict(WEEK_DAYS_SELECTION).get(line.day_number))} - "
f"""
{line.template_id.name
or dict(
self._fields['state']._description_selection(self.env)
)[line.state]}"""
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

line.template_id.name
or dict(self._fields["state"]._description_selection(self.env))[
line.state
]
}"""
)

@api.depends("planning_id", "day_number", "template_id")
Expand All @@ -428,7 +430,7 @@ def _compute_shift_time(self):
and shift.template_id._prepare_time()["end_time"]
or {"hour": 23, "minute": 59}
)
tz = pytz.timezone(shift.template_id.tz or self.env.user.tz)
tz = pytz.timezone(shift.template_id.tz or self.env.user.tz or "UTC")
start_time = tz.localize(
datetime.combine(
shift_date,
Expand All @@ -450,7 +452,7 @@ def _compute_shift_time(self):

def _compute_start_date(self):
for shift in self:
local_tz = pytz.timezone(shift.template_id.tz or self.env.user.tz)
local_tz = pytz.timezone(shift.template_id.tz or self.env.user.tz or "UTC")
shift.start_date = (
pytz.utc.localize(shift.start_time)
.astimezone(local_tz)
Expand All @@ -475,7 +477,7 @@ def _is_public_holiday(self):
def _is_on_leave(self):
if not (self.start_time and self.end_time and self.employee_id):
return False
local_tz = pytz.timezone(self.template_id.tz or self.env.user.tz)
local_tz = pytz.timezone(self.template_id.tz or self.env.user.tz or "UTC")
start_time = fields.datetime.combine(
pytz.utc.localize(self.start_time).astimezone(local_tz),
self.start_time.min.time(),
Expand Down
Loading