From e543edcc40ae3709d8c8f57b2324254510bc1906 Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Mon, 6 Mar 2023 09:53:38 +0100 Subject: [PATCH] [fix] regul wizard error for bordereau with no invoice --- wizard/scop_cotisation_cg_regul.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wizard/scop_cotisation_cg_regul.py b/wizard/scop_cotisation_cg_regul.py index 847f28d..bdc7b08 100644 --- a/wizard/scop_cotisation_cg_regul.py +++ b/wizard/scop_cotisation_cg_regul.py @@ -74,11 +74,15 @@ class ScopCotisationRegul(models.TransientModel): # ------------------------------------------------------ @api.constrains("date_regul") def _check_date_regul(self): - last_date = max(self.bordereau_id.invoice_ids.mapped("invoice_date")) + invoice_date = self.bordereau_id.invoice_ids.mapped("invoice_date") + if invoice_date: + last_date = max(invoice_date) + else: + last_date = self.bordereau_id.base_cotisation_cg.date_cotisation if self.date_regul > fields.Date.today() or self.date_regul < last_date: raise ValidationError( _( - "La date de régulation doit être " + "La date de régularisation doit être " "inférieure ou égale à la date du jour et " "supérieure à la dernière date de " "facturation liée au bordereau." -- GitLab