From 2b7208ee1cf4cb47e7d9036f227c592385918de3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 28 Aug 2019 13:45:13 +0200 Subject: Container: fix index on warehouse change --- archaeological_warehouse/forms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'archaeological_warehouse/forms.py') diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 58d856844..94d37d092 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -318,14 +318,14 @@ class ContainerModifyForm(ContainerForm): # manage unique ID cleaned_data = super(ContainerModifyForm, self).clean() index = cleaned_data.get("index", None) - warehouse = cleaned_data.get("location") + warehouse = cleaned_data.get("responsible") if not index: - q = models.Container.objects.filter(location__pk=warehouse) + q = models.Container.objects.filter(responsible__pk=warehouse) if not q.count(): cleaned_data["index"] = 1 else: - cleaned_data["index"] = q.all().aggregate( - Max("index"))["index__max"] + 1 + cleaned_data["index"] = int(q.aggregate( + Max("index"))["index__max"]) + 1 else: q = models.Container.objects.filter( index=index, location__pk=warehouse) -- cgit v1.2.3