From 985a2f4a52e9300ed419e8158d039e5a38e00486 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Sun, 20 Jan 2019 19:08:11 +0100 Subject: [PATCH] =?UTF-8?q?Choix=20de=20l'envoi=20du=20re=C3=A7u=20par=20m?= =?UTF-8?q?ail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/models.py | 6 +++++- ...061_cotisationsoption_send_voucher_mail.py | 20 +++++++++++++++++++ preferences/models.py | 4 ++++ .../preferences/display_preferences.html | 4 ++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 preferences/migrations/0061_cotisationsoption_send_voucher_mail.py diff --git a/cotisations/models.py b/cotisations/models.py index 42d76a08..64ef791d 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -46,6 +46,7 @@ from django.urls import reverse from django.shortcuts import redirect from django.contrib import messages +from preferences.models import CotisationsOption from machines.models import regen from re2o.field_permissions import FieldPermissionModelMixin from re2o.mixins import AclMixin, RevMixin @@ -255,7 +256,10 @@ class Facture(BaseInvoice): super(Facture, self).save(*args, **kwargs) if not self.__original_valid and self.valid: 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) def __str__(self): diff --git a/preferences/migrations/0061_cotisationsoption_send_voucher_mail.py b/preferences/migrations/0061_cotisationsoption_send_voucher_mail.py new file mode 100644 index 00000000..1476ef12 --- /dev/null +++ b/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.'), + ), + ] diff --git a/preferences/models.py b/preferences/models.py index 71f1ffa0..9e2988e0 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -729,3 +729,7 @@ class CotisationsOption(AclMixin, PreferencesModel): on_delete=models.PROTECT, default=default_voucher, ) + send_voucher_mail = models.BooleanField( + verbose_name=_("Send voucher by email when the invoice is controlled."), + default=False, + ) diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html index 92ac0915..f41e8397 100644 --- a/preferences/templates/preferences/display_preferences.html +++ b/preferences/templates/preferences/display_preferences.html @@ -361,6 +361,10 @@ with this program; if not, write to the Free Software Foundation, Inc., + + +
{% trans "Send voucher by email" %}{{ cotisationsoptions.send_voucher_mail | tick }} +
{% trans "Invoices' template" %} {{ cotisationsoptions.invoice_template }}