From 19cf3b4f83960a077cdb646e98b05d7c559ad068 Mon Sep 17 00:00:00 2001 From: chirac Date: Tue, 5 Jul 2016 14:01:29 +0200 Subject: [PATCH] =?UTF-8?q?Rend=20les=20champs=20banque=20et=20numero=20de?= =?UTF-8?q?=20ch=C3=A8que=20obligatoire=20si=20paiement=20par=20ch=C3=A8qu?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cotisations/models.py b/cotisations/models.py index eec3b1e2..6ea32e65 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -63,6 +63,16 @@ class NewFactureForm(ModelForm): model = Facture fields = ['paiement','banque','cheque','number'] + def clean(self): + cleaned_data=super(NewFactureForm, self).clean() + paiement = cleaned_data.get("paiement") + cheque = cleaned_data.get("cheque") + banque = cleaned_data.get("banque") + print(paiement.moyen) + if paiement.moyen=="chèque" and not (cheque and banque): + raise forms.ValidationError("Le numero de chèque et la banque sont obligatoires") + return cleaned_data + class EditFactureForm(NewFactureForm): class Meta(NewFactureForm.Meta): fields = '__all__'