From 7bbb859bc545e39a50980867077177e30714badf Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Thu, 20 Jul 2023 11:48:44 +0200 Subject: [PATCH] [FIX] rename get_work_days_data to _get_work_days_data_batch following this commit https://github.com/OCA/OCB/commit/8c96a887d3f05680c923dcd44f9c70c0e5e0bd32 --- .../models/resource_mixin.py | 6 +-- .../tests/test_work_days_data.py | 40 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/resource_work_time_from_contracts/models/resource_mixin.py b/resource_work_time_from_contracts/models/resource_mixin.py index d88fea9ef..442869f61 100644 --- a/resource_work_time_from_contracts/models/resource_mixin.py +++ b/resource_work_time_from_contracts/models/resource_mixin.py @@ -96,7 +96,7 @@ def list_normal_work_time_per_day(self, from_datetime, to_datetime, domain=None) day += delta return result - def get_work_days_data( + def _get_work_days_data_batch( self, from_datetime, to_datetime, @@ -105,7 +105,7 @@ def get_work_days_data( domain=None, ): if calendar or not hasattr(self, "contract_ids"): - return super().get_work_days_data( + return super()._get_work_days_data_batch( from_datetime, to_datetime, compute_leaves, calendar, domain ) # we need the normal work time per day for each day to be able to @@ -146,7 +146,7 @@ def get_work_days_data( continue normal_work_time = normal_work_time_per_day[day] # we use the same rounding computation as in - # resource.resource_mixin.get_work_days_data(). + # resource.resource_mixin._get_work_days_data_batch(). num_days += ( float_utils.round(ROUNDING_FACTOR * work_time / normal_work_time) / ROUNDING_FACTOR diff --git a/resource_work_time_from_contracts/tests/test_work_days_data.py b/resource_work_time_from_contracts/tests/test_work_days_data.py index 2f166499d..ca737abef 100644 --- a/resource_work_time_from_contracts/tests/test_work_days_data.py +++ b/resource_work_time_from_contracts/tests/test_work_days_data.py @@ -200,7 +200,7 @@ def test_with_leaves(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 25), self.local_datetime(2021, 11, 1), compute_leaves=False, @@ -211,7 +211,7 @@ def test_with_leaves(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 12, 30), ), @@ -221,7 +221,7 @@ def test_with_leaves(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 12, 30), compute_leaves=False, @@ -232,7 +232,7 @@ def test_with_leaves(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 13, 30), self.local_datetime(2021, 10, 26, 17, 18), ), @@ -242,7 +242,7 @@ def test_with_leaves(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 13, 30), self.local_datetime(2021, 10, 26, 17, 18), compute_leaves=False, @@ -253,7 +253,7 @@ def test_with_leaves(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 27, 8, 42), self.local_datetime(2021, 10, 27, 17, 18), ), @@ -263,7 +263,7 @@ def test_with_leaves(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 27, 8, 42), self.local_datetime(2021, 10, 27, 17, 18), compute_leaves=False, @@ -288,7 +288,7 @@ def test_precision(self): } ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 8, 48), ), @@ -298,7 +298,7 @@ def test_precision(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 9, 6), ), @@ -308,7 +308,7 @@ def test_precision(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 9, 18), ), @@ -318,7 +318,7 @@ def test_precision(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 9, 36), ), @@ -352,7 +352,7 @@ def test_timezone(self): } ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 12, 30), ), @@ -362,7 +362,7 @@ def test_timezone(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.local_datetime(2021, 10, 26, 8, 42), self.local_datetime(2021, 10, 26, 12, 30), compute_leaves=False, @@ -373,7 +373,7 @@ def test_timezone(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.to_utc_datetime(2021, 10, 26, 8, 42), self.to_utc_datetime(2021, 10, 26, 12, 30), ), @@ -383,7 +383,7 @@ def test_timezone(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.to_utc_datetime(2021, 10, 26, 8, 42), self.to_utc_datetime(2021, 10, 26, 12, 30), compute_leaves=False, @@ -394,7 +394,7 @@ def test_timezone(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.to_utc_datetime(2021, 10, 26, 8, 42).replace(tzinfo=None), self.to_utc_datetime(2021, 10, 26, 12, 30).replace(tzinfo=None), ), @@ -404,7 +404,7 @@ def test_timezone(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.to_utc_datetime(2021, 10, 26, 8, 42).replace(tzinfo=None), self.to_utc_datetime(2021, 10, 26, 12, 30).replace(tzinfo=None), compute_leaves=False, @@ -415,7 +415,7 @@ def test_timezone(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.to_utc_datetime(2021, 10, 26, 8, 42).astimezone( timezone(timedelta(hours=23)) ), @@ -429,7 +429,7 @@ def test_timezone(self): }, ) self.assertEqual( - self.employee1.get_work_days_data( + self.employee1._get_work_days_data_batch( self.to_utc_datetime(2021, 10, 26, 8, 42).astimezone( timezone(timedelta(hours=23)) ), @@ -447,4 +447,4 @@ def test_timezone(self): def _get_employee_work_days(self): from_datetime = self.local_datetime(2021, 10, 25) to_datetime = from_datetime + timedelta(days=7) - return self.employee1.get_work_days_data(from_datetime, to_datetime) + return self.employee1._get_work_days_data_batch(from_datetime, to_datetime)