diff --git a/eo_gestion/eo_facture/models.py b/eo_gestion/eo_facture/models.py index 6c8c70a..eae2c00 100644 --- a/eo_gestion/eo_facture/models.py +++ b/eo_gestion/eo_facture/models.py @@ -28,6 +28,7 @@ from django.db.models import F, Q, Sum from django.db.models.query import QuerySet from django.db.models.signals import post_delete, post_save from django.template.loader import get_template +from django.utils.encoding import force_text from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _ from weasyprint import HTML @@ -428,6 +429,13 @@ class Facture(models.Model): payment.save() return facture_avoir + def filename(self, add_client_name=False): + return '%s%s%s.pdf' % ( + self.code(), + '-%s' % force_text(self.contrat.client.nom) if add_client_name else '', + '-AVOIR' if self.annulation else '', + ) + class Meta: ordering = ("-id",) diff --git a/eo_gestion/eo_facture/templates/admin/eo_facture/facture/change_form.html b/eo_gestion/eo_facture/templates/admin/eo_facture/facture/change_form.html index 883b330..b6063d0 100644 --- a/eo_gestion/eo_facture/templates/admin/eo_facture/facture/change_form.html +++ b/eo_gestion/eo_facture/templates/admin/eo_facture/facture/change_form.html @@ -10,7 +10,7 @@ {% if original.contrat %}