From 3b1e37ce67a0161ea3c55d77ae7de80eda7990cf Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Thu, 30 Sep 2021 16:14:57 +0200 Subject: [PATCH] [FIX] hr_work_entry_contract: fix first batching While investigating an error that occured on production it was noticed that work entry batching did not happen correctly on the first batch for contracts that started on the same date, this is due to the microseconds being different in the `date_generated_from` and `date_generated_to` fields. TaskId-2466871 --- addons/hr_work_entry_contract/models/hr_contract.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/hr_work_entry_contract/models/hr_contract.py b/addons/hr_work_entry_contract/models/hr_contract.py index aff668a325a..1d085c74391 100644 --- a/addons/hr_work_entry_contract/models/hr_contract.py +++ b/addons/hr_work_entry_contract/models/hr_contract.py @@ -19,9 +19,10 @@ class HrContract(models.Model): _description = 'Employee Contract' date_generated_from = fields.Datetime(string='Generated From', readonly=True, required=True, - default=lambda self: datetime.now().replace(hour=0, minute=0, second=0), copy=False) + default=lambda self: datetime.now().replace(hour=0, minute=0, second=0, microsecond=0), copy=False) date_generated_to = fields.Datetime(string='Generated To', readonly=True, required=True, - default=lambda self: datetime.now().replace(hour=0, minute=0, second=0), copy=False) + default=lambda self: datetime.now().replace(hour=0, minute=0, second=0, microsecond=0), copy=False) + def _get_default_work_entry_type(self): return self.env.ref('hr_work_entry.work_entry_type_attendance', raise_if_not_found=False)