Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Employees Shifts

Entity: hr.shift.planning.line

Compute Method: _compute_shift_time

View 17.0
Inputs Method Outputs
  • template_id
  • planning_id
  • planning_id.start_date
  • day_number
  • template_id.tz
- for shift in self.filtered("shift_id"):
-             shift_date = shift.template_id._get_weekdate(
-                 shift.planning_id.start_date, int(shift.day_number)
-             )
-             start_time = shift.template_id._prepare_time()["start_time"]
-             end_time = (
-                 shift.template_id
-                 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)
-             start_time = tz.localize(
-                 datetime.combine(
-                     shift_date,
-                     datetime.min.time().replace(
-                         hour=start_time["hour"], minute=start_time["minute"]
-                     ),
-                 )
-             )
-             end_time = tz.localize(
-                 datetime.combine(
-                     shift_date,
-                     datetime.min.time().replace(
-                         hour=end_time["hour"], minute=end_time["minute"]
-                     ),
-                 )
-             )
-             shift.start_time = start_time.astimezone(pytz.UTC).replace(tzinfo=None)
-             shift.end_time = end_time.astimezone(pytz.UTC).replace(tzinfo=None)
  • start_time
  • end_time

Back to entity