From 2d2751c58d2ce9535b8127015f57fdfdc8281ca6 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Wed, 15 Feb 2023 17:53:37 +0530 Subject: [PATCH] fix: state ordering in group --- apiserver/plane/db/models/state.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apiserver/plane/db/models/state.py b/apiserver/plane/db/models/state.py index d66ecfa72..2fa1ebe38 100644 --- a/apiserver/plane/db/models/state.py +++ b/apiserver/plane/db/models/state.py @@ -38,4 +38,13 @@ class State(ProjectBaseModel): def save(self, *args, **kwargs): self.slug = slugify(self.name) + if self._state.adding: + # Get the maximum sequence value from the database + last_id = State.objects.filter(project=self.project).aggregate( + largest=models.Max("sequence") + )["largest"] + # if last_id is not None + if last_id is not None: + self.sequence = last_id + 15000 + return super().save(*args, **kwargs)