From 122703f830e14f7ce035c618d5aaa0239904011c Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Wed, 22 Dec 2021 14:29:38 +0100 Subject: [PATCH] [fix] version only if bordereau != new --- models/scop_cotisation_cg_exo.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index 5600d9f..399d584 100644 --- a/models/scop_cotisation_cg_exo.py +++ b/models/scop_cotisation_cg_exo.py @@ -405,14 +405,15 @@ class ScopCotisationExo(models.Model): # Update link exo - bordereau self.update({'bordereau_ids': [(4, bordereau_id.id)]}) - # 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, - }) + 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