From 777621fcec16f01d0eb596cf7709048f6130816c Mon Sep 17 00:00:00 2001 From: grisel-davy Date: Thu, 10 Sep 2020 15:15:31 +0200 Subject: [PATCH] Create new method to return number + name and add to template --- cotisations/models.py | 8 ++++++++ cotisations/templates/cotisations/aff_cotisations.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cotisations/models.py b/cotisations/models.py index dc415624..531b9672 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -95,6 +95,14 @@ class BaseInvoice(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): Vente.objects.filter(facture=self).values_list("name", flat=True) ) return name + + def name_detailled(self): + """ + Return: a string with the name of the article and the number + of article sold. + """ + vente = Vente.objects.filter(facture=self).get() + return str(vente.number) + " x " + str(vente.name) # TODO : change facture to invoice diff --git a/cotisations/templates/cotisations/aff_cotisations.html b/cotisations/templates/cotisations/aff_cotisations.html index b9a1a810..cb7ae2c8 100644 --- a/cotisations/templates/cotisations/aff_cotisations.html +++ b/cotisations/templates/cotisations/aff_cotisations.html @@ -59,7 +59,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% for facture in facture_list %} {{ facture.user }} - {{ facture.name }} + {{ facture.name_detailled }} {{ facture.prix_total }} {{ facture.paiement }} {{ facture.date }}