mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 14:42:25 +00:00
Rend les champs banque et numero de chèque obligatoire si paiement par chèque
This commit is contained in:
parent
ee9b6e4c88
commit
209ff89b7d
1 changed files with 10 additions and 0 deletions
|
@ -63,6 +63,16 @@ class NewFactureForm(ModelForm):
|
||||||
model = Facture
|
model = Facture
|
||||||
fields = ['paiement','banque','cheque','number']
|
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 EditFactureForm(NewFactureForm):
|
||||||
class Meta(NewFactureForm.Meta):
|
class Meta(NewFactureForm.Meta):
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
Loading…
Reference in a new issue