Browse Source

[FIX] b_shift : datetime.combine() method for python 3.4

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
11f0d190ea
  1. 10
      beesdoo_shift/models/planning.py
  2. 2
      beesdoo_shift/wizard/instanciate_planning.py

10
beesdoo_shift/models/planning.py

@ -100,11 +100,15 @@ class TaskTemplate(models.Model):
end_date = fields.Datetime(compute="_get_fake_date", search="_dummy_search") end_date = fields.Datetime(compute="_get_fake_date", search="_dummy_search")
def _get_utc_date(self, day, hour, minute): def _get_utc_date(self, day, hour, minute):
"""Combine day number, hours and minutes to save
corresponding UTC datetime in database.
"""
context_tz = timezone(self._context.get('tz') or self.env.user.tz) context_tz = timezone(self._context.get('tz') or self.env.user.tz)
day_local_time=datetime.combine(day, time(hour=hour, minute=minute), tzinfo=context_tz)
day_utc_time=day_local_time.astimezone(UTC)
day_local_time = datetime.combine(day, time(hour=hour, minute=minute))
day_local_time = context_tz.localize(day_local_time)
day_utc_time = day_local_time.astimezone(UTC)
# Return naïve datetime so as to be saved in database # Return naïve datetime so as to be saved in database
return day_utc_time.replace(tzinfo=None)
return day_utc_time.replace(tzinfo=None)
@api.depends('start_time', 'end_time') @api.depends('start_time', 'end_time')
def _get_fake_date(self): def _get_fake_date(self):

2
beesdoo_shift/wizard/instanciate_planning.py

@ -7,7 +7,7 @@ class InstanciatePlanning(models.TransientModel):
def _get_planning(self): def _get_planning(self):
return self._context.get('active_id') return self._context.get('active_id')
date_start = fields.Date("First Day of planning", required=True)
date_start = fields.Date("First Day of planning (should be monday)", required=True)
planning_id = fields.Many2one('beesdoo.shift.planning', readonly=True, default=_get_planning) planning_id = fields.Many2one('beesdoo.shift.planning', readonly=True, default=_get_planning)
@api.multi @api.multi

Loading…
Cancel
Save