diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index c30977491755353550f05d72ec03c5e94679ded5..031f204d857effc99a0b2884c0a4a631cde40f4d 100644 --- a/models/scop_cotisation_cg_exo.py +++ b/models/scop_cotisation_cg_exo.py @@ -354,7 +354,25 @@ class ScopCotisationExo(models.Model): return quarters def create_exo_refund(self, bordereau_id): + """ + - Create version before any change + - Create needed refund + """ bordereau_id.ensure_one() + + # Create version + if bordereau_id.state != 'new': + self.env['scop.bordereau.version'].create({ + 'bordereau_id': bordereau_id.id, + 'date': self.date_exo_ok, + 'comment': "Exonération", + 'version': bordereau_id.version, + 'liasse_fiscale_id_old': bordereau_id.liasse_fiscale_id.id, + 'type_assiette': bordereau_id.type_assiette, + 'montant_assiette': bordereau_id.montant_assiette, + 'amount_total_cotiz': bordereau_id.amount_total_cotiz, + }) + exo_quarters = self.get_quarters() # check exo period exo_period = exo_quarters[bordereau_id.year] @@ -418,16 +436,3 @@ class ScopCotisationExo(models.Model): }) # Update link exo - bordereau self.update({'bordereau_ids': [(4, bordereau_id.id)]}) - - if bordereau_id.state != 'new': - # Create version - self.env['scop.bordereau.version'].create({ - 'bordereau_id': bordereau_id.id, - 'date': self.date_exo_ok, - 'comment': "Exonération", - 'version': bordereau_id.version, - 'liasse_fiscale_id_old': bordereau_id.liasse_fiscale_id.id, - 'type_assiette': bordereau_id.type_assiette, - 'montant_assiette': bordereau_id.montant_assiette, - 'amount_total_cotiz': bordereau_id.amount_total_cotiz, - })