8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 03:13:12 +00:00

Linked_objects + fix modif formset

This commit is contained in:
Gabriel Detraz 2018-04-02 03:52:15 +02:00 committed by chirac
parent 88b003d0fe
commit 6db387caf8
3 changed files with 12 additions and 2 deletions

View file

@ -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"""

View file

@ -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({

View file

@ -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