From 12c78be4ec9f89325ad80c148c92b6a306969bb5 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 11 Feb 2021 16:55:12 +0100 Subject: Container: generate index by location not responsibility --- archaeological_warehouse/models.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'archaeological_warehouse/models.py') 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 -- cgit v1.2.3