From a33c9727f542d68b8d288dbe260df3380c3a1f26 Mon Sep 17 00:00:00 2001 From: Lorenzo <99982085+LorenzoC0@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:33:28 +0200 Subject: [PATCH] [IMP] Improved fiscal year generation on unit test (#113) --- l10n_it_asset_management/tests/common.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/l10n_it_asset_management/tests/common.py b/l10n_it_asset_management/tests/common.py index b307a145b18d..351c29dd65a6 100644 --- a/l10n_it_asset_management/tests/common.py +++ b/l10n_it_asset_management/tests/common.py @@ -186,6 +186,9 @@ def _depreciate_asset_wizard( period_count=None, override_journal=None, ): + first_of_year = date_dep.replace(month=1, day=1) + last_of_year = date_dep.replace(month=12, day=31) + self._generate_fiscal_years(first_of_year, last_of_year) if override_journal is None: override_journal = self.env["account.journal"].browse() wiz_vals = asset.with_context( @@ -326,10 +329,9 @@ def _civil_depreciate_asset(self, asset): return True def _generate_fiscal_years(self, start_date, end_date): - fiscal_years = range( - start_date.year, - end_date.year + 1, - ) + fiscal_years = set() + for year in range(start_date.year, end_date.year + 1): + fiscal_years.add(year) fiscal_years_values = list() for fiscal_year in fiscal_years: fiscal_year_values = {