Browse Source

Choix de l'envoi du reçu par mail

mac_vendor
Hugo LEVY-FALK 7 years ago
parent
commit
985a2f4a52
  1. 6
      cotisations/models.py
  2. 20
      preferences/migrations/0061_cotisationsoption_send_voucher_mail.py
  3. 4
      preferences/models.py
  4. 4
      preferences/templates/preferences/display_preferences.html

6
cotisations/models.py

@ -46,6 +46,7 @@ from django.urls import reverse
from django.shortcuts import redirect from django.shortcuts import redirect
from django.contrib import messages from django.contrib import messages
from preferences.models import CotisationsOption
from machines.models import regen from machines.models import regen
from re2o.field_permissions import FieldPermissionModelMixin from re2o.field_permissions import FieldPermissionModelMixin
from re2o.mixins import AclMixin, RevMixin from re2o.mixins import AclMixin, RevMixin
@ -255,7 +256,10 @@ class Facture(BaseInvoice):
super(Facture, self).save(*args, **kwargs) super(Facture, self).save(*args, **kwargs)
if not self.__original_valid and self.valid: if not self.__original_valid and self.valid:
send_mail_invoice(self) send_mail_invoice(self)
if self.is_subscription() and not self.__original_control and self.control: if self.is_subscription() \
and not self.__original_control \
and self.control \
and CotisationsOption.get_cached_value('send_voucher_mail'):
send_mail_voucher(self) send_mail_voucher(self)
def __str__(self): def __str__(self):

20
preferences/migrations/0061_cotisationsoption_send_voucher_mail.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2019-01-20 18:03
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0060_assooption_pres_name'),
]
operations = [
migrations.AddField(
model_name='cotisationsoption',
name='send_voucher_mail',
field=models.BooleanField(default=False, verbose_name='Send voucher by email when the invoice is controlled.'),
),
]

4
preferences/models.py

@ -729,3 +729,7 @@ class CotisationsOption(AclMixin, PreferencesModel):
on_delete=models.PROTECT, on_delete=models.PROTECT,
default=default_voucher, default=default_voucher,
) )
send_voucher_mail = models.BooleanField(
verbose_name=_("Send voucher by email when the invoice is controlled."),
default=False,
)

4
preferences/templates/preferences/display_preferences.html

@ -361,6 +361,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
</a> </a>
<table class="table table-striped"> <table class="table table-striped">
<tr>
<th>{% trans "Send voucher by email" %}</th>
<td>{{ cotisationsoptions.send_voucher_mail | tick }}</th>
</tr>
<tr> <tr>
<th>{% trans "Invoices' template" %}</th> <th>{% trans "Invoices' template" %}</th>
<td>{{ cotisationsoptions.invoice_template }}</td> <td>{{ cotisationsoptions.invoice_template }}</td>

Loading…
Cancel
Save