From 40922cc02772d4c4574e994391992ca7ec8d6dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 7 Aug 2018 13:34:06 +0200 Subject: [PATCH] [FIX] hr_holidays: fix date computation Since date / datetime refactoring done at 960360afe478a8f7b9c456721b5591154952a37d we cannot encode new leave requests or new allocation requests anymore. This commit fixes that by correctly setting date / datetime on date / datetime field and correctly computing one from the other. --- addons/hr_holidays/models/hr_leave.py | 8 ++++---- addons/hr_holidays/models/hr_leave_allocation.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index c2e2e2df44f..201c62eb8f0 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -247,8 +247,8 @@ class HolidaysRequest(models.Model): date_to = date_from + timedelta(hours=self.employee_id.resource_calendar_id.hours_per_day) self.date_to = date_to - self.request_date_from = date_from - self.request_date_to = date_to + self.request_date_from = date_from.date() + self.request_date_to = date_to.date() if (date_from and date_to) and (date_from.day < date_to.day): self.request_unit_all = 'period' @@ -266,8 +266,8 @@ class HolidaysRequest(models.Model): date_from = fields.Datetime.from_string(self.date_from) date_to = fields.Datetime.from_string(self.date_to) - self.request_date_from = date_from - self.request_date_to = date_to + self.request_date_from = date_from.date() + self.request_date_to = date_to.date() if (date_from and date_to) and (date_from.day < date_to.day): self.request_unit_all = 'period' diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index 297a510030a..7e952ebe42d 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -248,7 +248,7 @@ class HolidaysAllocation(models.Model): @api.onchange('holiday_status_id') def _onchange_holiday_status_id(self): - self.date_to = self.holiday_status_id.validity_stop + self.date_to = datetime.combine(self.holiday_status_id.validity_stop, datetime.max.time()) if self.accrual: self.number_of_days_temp = 0