From 3b1e37ce67a0161ea3c55d77ae7de80eda7990cf Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Thu, 30 Sep 2021 16:14:57 +0200 Subject: [PATCH 1/2] [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) From f51afa1ed43d74731c14037c11ac8f8c27b427c9 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Tue, 22 Jun 2021 17:19:27 +0200 Subject: [PATCH 2/2] [IMP] hr_work_entry_contract: prep work for multiple sources Prep work to allow work entries to be created from multiple sources when using contracts. The end goal is to be able to generate work entries from attendance as well as the planning app. After that the plan is to make sure the implementation works well with payroll for hourly wages. This commit contains the necessary changes for the next work_entry modules to work. TaskId-2466871 --- .../hr_contract/views/hr_contract_views.xml | 2 +- addons/hr_work_entry/models/hr_work_entry.py | 2 +- addons/hr_work_entry_contract/__manifest__.py | 1 + .../models/hr_contract.py | 127 +++++++++++++----- .../models/hr_work_entry.py | 1 + .../views/hr_contract_views.xml | 14 ++ .../hr_work_entry_regeneration_wizard.py | 6 +- .../models/hr_contract.py | 2 +- addons/resource/models/resource.py | 5 +- 9 files changed, 117 insertions(+), 43 deletions(-) create mode 100644 addons/hr_work_entry_contract/views/hr_contract_views.xml diff --git a/addons/hr_contract/views/hr_contract_views.xml b/addons/hr_contract/views/hr_contract_views.xml index ce1599de10b..7ac94420a59 100644 --- a/addons/hr_contract/views/hr_contract_views.xml +++ b/addons/hr_contract/views/hr_contract_views.xml @@ -160,7 +160,7 @@