From 0ecfcb0c08ec6f0eb94c8dff0a135d28f9ba8cd4 Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Tue, 23 Aug 2022 14:16:02 +0200
Subject: [PATCH] [add] throw error if no exo lines

---
 models/scop_cotisation_cg_exo.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py
index 38ecccb..82b77f5 100644
--- a/models/scop_cotisation_cg_exo.py
+++ b/models/scop_cotisation_cg_exo.py
@@ -335,6 +335,13 @@ class ScopCotisationExo(models.Model):
             raise UserError(
                 _("Il est nécessaire de renseigner une date d'acceptation pour valider")
             )
+        elif not self.exo_line_ids:
+            raise UserError(
+                _(
+                    "Aucune ligne d'exonération n'a été créée. "
+                    "Veuillez cliquer sur le bouton Créer/Mettre à jour les lignes"
+                )
+            )
         else:
             # Unfavorable => nothing to do
             if self.final_notice == "unfavorable":
-- 
GitLab