diff --git a/cotisations/models.py b/cotisations/models.py index 10aa868e..cdf73a39 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -88,6 +88,11 @@ class Facture(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): ("change_all_facture", "Superdroit, peut modifier toutes les factures"), ) + def linked_objects(self): + """Return linked objects : machine and domain. + Usefull in history display""" + return self.vente_set.all() + def prix(self): """Renvoie le prix brut sans les quantités. Méthode dépréciée""" diff --git a/cotisations/views.py b/cotisations/views.py index 6bf58994..b78a82f5 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -251,8 +251,7 @@ def edit_facture(request, facture, factureid): if facture_form.is_valid() and vente_form.is_valid(): if facture_form.changed_data: facture_form.save() - if vente_form.changed_data: - vente_form.save() + vente_form.save() messages.success(request, "La facture a bien été modifiée") return redirect(reverse('cotisations:index')) return form({ diff --git a/machines/models.py b/machines/models.py index c7d9fe83..dc2dba65 100644 --- a/machines/models.py +++ b/machines/models.py @@ -27,6 +27,7 @@ from datetime import timedelta import re from netaddr import mac_bare, EUI, IPSet, IPRange, IPNetwork, IPAddress from ipaddress import IPv6Address +from itertools import chain from django.db import models from django.db.models.signals import post_save, post_delete @@ -72,6 +73,11 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): """ return Machine.objects.get(pk=machineid) + def linked_objects(self): + """Return linked objects : machine and domain. + Usefull in history display""" + return chain(self.interface_set.all(), Domain.objects.filter(interface_parent__in=self.interface_set.all())) + @staticmethod def can_change_user(user_request, *args, **kwargs): """Checks if an user is allowed to change the user who owns a