diff --git a/cotisations/forms.py b/cotisations/forms.py index e3c38f7a..f8b8afba 100644 --- a/cotisations/forms.py +++ b/cotisations/forms.py @@ -34,6 +34,7 @@ class NewFactureForm(ModelForm): self.fields['cheque'].label = 'Numero de chèque' 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 class Meta: model = Facture diff --git a/cotisations/models.py b/cotisations/models.py index b716f836..a25ed445 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -172,6 +172,11 @@ class Paiement(models.Model): def clean(self): self.moyen = self.moyen.title() + def save(self, *args, **kwargs): + if Paiement.objects.filter(type_paiement=1).count() > 1: + raise ValidationError("On ne peut avoir plusieurs mode de paiement chèque") + super(Paiement, self).save(*args, **kwargs) + class Cotisation(models.Model): PRETTY_NAME = "Cotisations" diff --git a/cotisations/templates/cotisations/aff_article.html b/cotisations/templates/cotisations/aff_article.html index 11644c8b..b756f746 100644 --- a/cotisations/templates/cotisations/aff_article.html +++ b/cotisations/templates/cotisations/aff_article.html @@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,