From 7935b6536ca95d100ed93d1273bdee389ed7b1c5 Mon Sep 17 00:00:00 2001 From: chirac Date: Mon, 6 Nov 2017 01:30:06 +0100 Subject: [PATCH] Fix bug quand il n'y a pas d'articles --- cotisations/forms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cotisations/forms.py b/cotisations/forms.py index 354da1f1..7725016c 100644 --- a/cotisations/forms.py +++ b/cotisations/forms.py @@ -56,8 +56,10 @@ class NewFactureForm(ModelForm): self.fields['banque'].empty_label = "Non renseigné" self.fields['paiement'].empty_label = "Séléctionner\ un moyen de paiement" - self.fields['paiement'].widget.attrs['data-cheque'] = Paiement.objects\ - .filter(type_paiement=1).first().id + paiement_list = Paiement.objects.filter(type_paiement=1) + if paiement_list: + self.fields['paiement'].widget\ + .attrs['data-cheque'] = paiement_list.first().id class Meta: model = Facture