[FIX] hr_payroll: Generate work entry for full days

Currently, `generate_work_entry` has a different behavior
if the type of parameters is `date` or `datetime`:
If the type is `date`, it implicitely set hours and minutes
to 00:00.
It is particularly confusing when `date_stop` is a `date`:
work entries are not generated for this day because it's
actually outside of the range.

This commit makes it consistent in all cases:
-hours and minutes are set to 00:00 for start date
-hours and minutes are set to 23:59 for end date

closes odoo/odoo#33906

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Lucas Lefèvre
2019-06-05 11:35:21 +00:00
parent 9bcc0498c0
commit 05ed9ebbe5
+3 -2
View File
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import datetime
from dateutil.relativedelta import relativedelta
import pytz
from odoo import api, fields, models
@@ -22,8 +23,8 @@ class HrEmployee(models.Model):
@api.multi
def generate_benefit(self, date_start, date_stop):
date_start = fields.Datetime.to_datetime(date_start)
date_stop = fields.Datetime.to_datetime(date_stop)
date_start = fields.Datetime.to_datetime(date_start) + relativedelta(hour=0, minute=0, second=0)
date_stop = fields.Datetime.to_datetime(date_stop) + relativedelta(hour=23, minute=59, second=59)
attendance_type = self.env.ref('hr_payroll.benefit_type_attendance')
vals_list = []