diff options
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 |
commit | a2cff1951871f2a59cb3c252d759358bff5f5fa4 (patch) | |
tree | dab32e80f0cee35c8597f8eb5f5432f2de814f89 /archaeological_warehouse/models.py | |
parent | 922adb6548078da98db30000bb0bf4ea17a40be5 (diff) | |
download | Ishtar-a2cff1951871f2a59cb3c252d759358bff5f5fa4.tar.bz2 Ishtar-a2cff1951871f2a59cb3c252d759358bff5f5fa4.zip |
Container: generate index by location not responsibility
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r-- | archaeological_warehouse/models.py | 24 |
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 |