Commit 84617e24 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Fix js paiement

parent 00c72ade
......@@ -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
......
......@@ -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"
......
......@@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<td>{{ article.name }}</td>
<td>{{ article.prix }}</td>
<td>{{ article.cotisation }}</td>
<td>{{ article.iscotisation }}</td>
<td>{{ article.duration }}</td>
<td class="text-right">
{% if is_trez %}
......
......@@ -109,9 +109,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
}
function set_cheque_info_visibility(){
var paiement = document.getElementById("id_paiement");
var visible = paiement.value != '' &&
paiement.children[paiement.value].dataset['type'] == 'check';
var visible = document.getElementById("id_paiement").value == document.getElementById("id_paiement").getAttribute('data-cheque');
p = document.getElementById("id_paiement")
console.log(p);
var display = 'none';
if (visible) {
display = 'block';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment