From d174136026caf3ce0e98385b3dd145622a03d252 Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Tue, 23 Aug 2022 15:57:05 +0200 Subject: [PATCH] [update] rage exo year: from 2016 --- models/scop_cotisation_cg_exo.py | 21 +++++++++++---------- models/scop_instance.py | 5 +---- views/scop_cotisation_cg_exo.xml | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index 3c75c45..73b9b8b 100644 --- a/models/scop_cotisation_cg_exo.py +++ b/models/scop_cotisation_cg_exo.py @@ -74,14 +74,14 @@ class ScopCotisationExo(models.Model): selection=QUARTER_SELECTION, string="Trimestre initial" ) year_exo_start = fields.Selection( - selection=[(str(year), str(year)) for year in range(2021, 2035)], + selection=[(str(year), str(year)) for year in range(2016, 2035)], string="Année initiale", ) quarter_exo_end = fields.Selection( selection=QUARTER_SELECTION, string="Trimestre final" ) year_exo_end = fields.Selection( - selection=[(str(year), str(year)) for year in range(2021, 2035)], + selection=[(str(year), str(year)) for year in range(2016, 2035)], string="Année finale", ) date_exo_start = fields.Date( @@ -346,20 +346,21 @@ class ScopCotisationExo(models.Model): # Unfavorable => nothing to do if self.final_notice == "unfavorable": self.state = "done" - + elif self.year_exo_start <= "2021" and self.year_exo_end <= "2021": + self.state = "done" # Favorable elif self.final_notice == "favorable": + if self.year_exo_start <= "2021": + exo_start = 2022 + else: + exo_start = int(self.year_exo_start) bordereau_ids = self.env["scop.bordereau"].search( [ ("partner_id", "=", self.partner_id.id), ( "year", "in", - list( - range( - int(self.year_exo_start), int(self.year_exo_end) + 1 - ) - ), + list(range(exo_start, int(self.year_exo_end) + 1)), ), ("state", "!=", "cancel"), ], @@ -414,7 +415,7 @@ class ScopCotisationExo(models.Model): """ quarters = {} if self.year_exo_start == self.year_exo_end: - quarters[self.year_exo_start] = range( + quarters[int(self.year_exo_start)] = range( int(self.quarter_exo_start), int(self.quarter_exo_end) + 1 ) else: @@ -451,7 +452,7 @@ class ScopCotisationExo(models.Model): exo_quarters = self.get_quarters() # check exo period - exo_period = exo_quarters[bordereau_id.year] + exo_period = exo_quarters[int(bordereau_id.year)] # Quarter loop for quarter in exo_period: diff --git a/models/scop_instance.py b/models/scop_instance.py index bbf3f5f..4629446 100644 --- a/models/scop_instance.py +++ b/models/scop_instance.py @@ -17,10 +17,7 @@ class ScopInstance(models.Model): all_exo_validated = fields.Boolean( compute="_compute_all_exo_validated", default=False ) - number_exo = fields.Integer( - string="Nombre d'exo", - compute="_compute_number_exo" - ) + number_exo = fields.Integer(string="Nombre d'exo", compute="_compute_number_exo") # ------------------------------------------------------ # Computed fields / Search Fields diff --git a/views/scop_cotisation_cg_exo.xml b/views/scop_cotisation_cg_exo.xml index b817db0..3415724 100644 --- a/views/scop_cotisation_cg_exo.xml +++ b/views/scop_cotisation_cg_exo.xml @@ -10,7 +10,7 @@ <field name="model">scop.cotisation.cg.exo</field> <field name="arch" type="xml"> <search string="Exonerations"> - <field name="partner_id" /> + <field name="partner_id" options="{'no_create': 1}" /> <field name="name" /> <field name="date_request" /> <separator /> -- GitLab