diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index 3c75c4559129e3ca8c9ff89c9497c8d37e3bf4d7..73b9b8bdd2104fa006149d719e0a90f591fc85a8 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 bbf3f5fd14995c7f010585fa23dcd6fecc8d3345..4629446f3fcd18b7341be8edbe0705901032e104 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 b817db03e198999a356012f07842bec0269b425e..341572402b621f2cf0ed85694472a2b351e8a24e 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 />