Skip to content

Commit

Permalink
[FIX] rename get_work_days_data to _get_work_days_data_batch
Browse files Browse the repository at this point in the history
following this commit OCA/OCB@8c96a88
  • Loading branch information
victor-champonnois committed Jul 20, 2023
1 parent ec6e12b commit 7bbb859
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions resource_work_time_from_contracts/models/resource_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions resource_work_time_from_contracts/tests/test_work_days_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
),
Expand All @@ -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,
Expand All @@ -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),
),
Expand All @@ -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,
Expand All @@ -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),
),
Expand All @@ -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,
Expand All @@ -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),
),
Expand All @@ -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),
),
Expand All @@ -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),
),
Expand All @@ -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),
),
Expand Down Expand Up @@ -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),
),
Expand All @@ -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,
Expand All @@ -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),
),
Expand All @@ -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,
Expand All @@ -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),
),
Expand All @@ -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,
Expand All @@ -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))
),
Expand All @@ -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))
),
Expand All @@ -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)

0 comments on commit 7bbb859

Please sign in to comment.