From de788947693b3873d8f40420814aa4e4e065d09c Mon Sep 17 00:00:00 2001 From: jordan <jordan@le-filament.com> Date: Thu, 24 Feb 2022 11:52:23 +0100 Subject: [PATCH] [fix] create version bordereau at the beginning of exo process --- models/scop_cotisation_cg_exo.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index c309774..031f204 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, - }) -- GitLab