diff options
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 |
commit | db76313a941d9d859e023e300b672628d761b4a1 (patch) | |
tree | 01734c6be3dae8b459ac9addb163c0fd988915fc /archaeological_warehouse/forms.py | |
parent | 55533e91d4c004a2e11b42019156f3f1edf8c3e0 (diff) | |
download | Ishtar-db76313a941d9d859e023e300b672628d761b4a1.tar.bz2 Ishtar-db76313a941d9d859e023e300b672628d761b4a1.zip |
Container: fix index on warehouse change
Diffstat (limited to 'archaeological_warehouse/forms.py')
-rw-r--r-- | archaeological_warehouse/forms.py | 8 |
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) |