feat: suppression des coulées lors de la copie

This commit is contained in:
François Poulain 2024-06-07 09:59:28 +02:00
parent 06bcebdc83
commit 065ee38f58

View File

@ -165,8 +165,12 @@ class FournéeAdmin(nested_admin.NestedModelAdmin):
save_on_top = True save_on_top = True
def save_related(self, request, form, formsets, change): def save_related(self, request, form, formsets, change):
"""Création des coulées manquantes"""
super().save_related(request, form, formsets, change) super().save_related(request, form, formsets, change)
"""Suppression des coulées en cas de copie"""
if "_saveasnew" in request.POST:
form.instance.coulée_set.all().delete()
"""Création des coulées manquantes si demandé"""
if change and "_continueandcreatecoulees" in request.POST: if change and "_continueandcreatecoulees" in request.POST:
obj = form.instance obj = form.instance