Commit 6db387ca authored by Gabriel Detraz's avatar Gabriel Detraz Committed by chirac

Linked_objects + fix modif formset

parent 88b003d0
......@@ -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"""
......
......@@ -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({
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment