mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Linked_objects + fix modif formset
This commit is contained in:
parent
88b003d0fe
commit
6db387caf8
3 changed files with 12 additions and 2 deletions
|
@ -88,6 +88,11 @@ class Facture(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
|
||||||
("change_all_facture", "Superdroit, peut modifier toutes les factures"),
|
("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):
|
def prix(self):
|
||||||
"""Renvoie le prix brut sans les quantités. Méthode
|
"""Renvoie le prix brut sans les quantités. Méthode
|
||||||
dépréciée"""
|
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.is_valid() and vente_form.is_valid():
|
||||||
if facture_form.changed_data:
|
if facture_form.changed_data:
|
||||||
facture_form.save()
|
facture_form.save()
|
||||||
if vente_form.changed_data:
|
vente_form.save()
|
||||||
vente_form.save()
|
|
||||||
messages.success(request, "La facture a bien été modifiée")
|
messages.success(request, "La facture a bien été modifiée")
|
||||||
return redirect(reverse('cotisations:index'))
|
return redirect(reverse('cotisations:index'))
|
||||||
return form({
|
return form({
|
||||||
|
|
|
@ -27,6 +27,7 @@ from datetime import timedelta
|
||||||
import re
|
import re
|
||||||
from netaddr import mac_bare, EUI, IPSet, IPRange, IPNetwork, IPAddress
|
from netaddr import mac_bare, EUI, IPSet, IPRange, IPNetwork, IPAddress
|
||||||
from ipaddress import IPv6Address
|
from ipaddress import IPv6Address
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.signals import post_save, post_delete
|
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)
|
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
|
@staticmethod
|
||||||
def can_change_user(user_request, *args, **kwargs):
|
def can_change_user(user_request, *args, **kwargs):
|
||||||
"""Checks if an user is allowed to change the user who owns a
|
"""Checks if an user is allowed to change the user who owns a
|
||||||
|
|
Loading…
Reference in a new issue