summaryrefslogtreecommitdiff
path: root/archaeological_warehouse
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-11 16:55:12 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:24 +0100
commit12c78be4ec9f89325ad80c148c92b6a306969bb5 (patch)
treedab32e80f0cee35c8597f8eb5f5432f2de814f89 /archaeological_warehouse
parent94af046feac22e336f8f5b4e55cc2394ee30bf97 (diff)
downloadIshtar-12c78be4ec9f89325ad80c148c92b6a306969bb5.tar.bz2
Ishtar-12c78be4ec9f89325ad80c148c92b6a306969bb5.zip
Container: generate index by location not responsibility
Diffstat (limited to 'archaeological_warehouse')
-rw-r--r--archaeological_warehouse/models.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 25a57c4ae..db08c3467 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -1380,20 +1380,12 @@ class Container(DocumentItem, Merge, LightHistorizedItem,
q = q.exclude(id=self.id)
if self.index and not q.count():
return
- if settings.ISHTAR_CONTAINER_INDEX == "general":
- q = Container.objects
- if q.count():
- self.index = int(
- q.all().aggregate(Max("index"))["index__max"] or 0) + 1
- else:
- self.index = 1
- else: # default is index by warehouse
- q = Container.objects.filter(location=self.location)
- if q.count():
- self.index = int(
- q.all().aggregate(Max("index"))["index__max"]) + 1
- else:
- self.index = 1
+ q = Container.objects.filter(location=self.location)
+ if q.count():
+ self.index = int(
+ q.all().aggregate(Max("index"))["index__max"]) + 1
+ else:
+ self.index = 1
if not self.cached_division:
self.cached_division = self._generate_cached_division()
@@ -1418,8 +1410,8 @@ class Container(DocumentItem, Merge, LightHistorizedItem,
if not self.index and not self.container_type.stationary:
self.skip_history_when_saving = True
q = Container.objects.filter(
- responsibility=self.responsibility).exclude(
- pk=self.pk).order_by('-index')
+ location=self.location
+ ).exclude(pk=self.pk).order_by('-index')
self.index = q.all()[0].index + 1 if q.count() else 1
updated = True