summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-08-28 13:45:13 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-08-28 13:45:13 +0200
commit2b7208ee1cf4cb47e7d9036f227c592385918de3 (patch)
tree01734c6be3dae8b459ac9addb163c0fd988915fc /archaeological_warehouse/forms.py
parentbbc390acb9137292085abe67b296220ebf9fdfbf (diff)
downloadIshtar-2b7208ee1cf4cb47e7d9036f227c592385918de3.tar.bz2
Ishtar-2b7208ee1cf4cb47e7d9036f227c592385918de3.zip
Container: fix index on warehouse change
Diffstat (limited to 'archaeological_warehouse/forms.py')
-rw-r--r--archaeological_warehouse/forms.py8
1 files changed, 4 insertions, 4 deletions
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)