diff options
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 | 
