8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 20:03:11 +00:00

Fix js paiement

This commit is contained in:
Gabriel Detraz 2017-09-04 15:31:48 +02:00 committed by root
parent 00c72ade80
commit 84617e2460
4 changed files with 10 additions and 4 deletions

View file

@ -34,6 +34,7 @@ class NewFactureForm(ModelForm):
self.fields['cheque'].label = 'Numero de chèque' self.fields['cheque'].label = 'Numero de chèque'
self.fields['banque'].empty_label = "Non renseigné" self.fields['banque'].empty_label = "Non renseigné"
self.fields['paiement'].empty_label = "Séléctionner un moyen de paiement" 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: class Meta:
model = Facture model = Facture

View file

@ -172,6 +172,11 @@ class Paiement(models.Model):
def clean(self): def clean(self):
self.moyen = self.moyen.title() 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): class Cotisation(models.Model):
PRETTY_NAME = "Cotisations" PRETTY_NAME = "Cotisations"

View file

@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr> <tr>
<td>{{ article.name }}</td> <td>{{ article.name }}</td>
<td>{{ article.prix }}</td> <td>{{ article.prix }}</td>
<td>{{ article.cotisation }}</td> <td>{{ article.iscotisation }}</td>
<td>{{ article.duration }}</td> <td>{{ article.duration }}</td>
<td class="text-right"> <td class="text-right">
{% if is_trez %} {% if is_trez %}

View file

@ -109,9 +109,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
} }
function set_cheque_info_visibility(){ function set_cheque_info_visibility(){
var paiement = document.getElementById("id_paiement"); var visible = document.getElementById("id_paiement").value == document.getElementById("id_paiement").getAttribute('data-cheque');
var visible = paiement.value != '' && p = document.getElementById("id_paiement")
paiement.children[paiement.value].dataset['type'] == 'check'; console.log(p);
var display = 'none'; var display = 'none';
if (visible) { if (visible) {
display = 'block'; display = 'block';