mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-12 00:19:48 +00:00
Fix: Getting next ASN when no documents have an ASN (#5431)
* Fixes the next ASN logic to account for no ASNs yet being assigned * Updates so the ASN will start at 1 * Do the same calculation without the branch
This commit is contained in:
@@ -757,16 +757,12 @@ class UnifiedSearchViewSet(DocumentViewSet):
|
||||
|
||||
@action(detail=False, methods=["GET"], name="Get Next ASN")
|
||||
def next_asn(self, request, *args, **kwargs):
|
||||
return Response(
|
||||
(
|
||||
Document.objects.filter(archive_serial_number__gte=0)
|
||||
.order_by("archive_serial_number")
|
||||
.last()
|
||||
.archive_serial_number
|
||||
or 0
|
||||
)
|
||||
+ 1,
|
||||
max_asn = Document.objects.aggregate(
|
||||
Max("archive_serial_number", default=0),
|
||||
).get(
|
||||
"archive_serial_number__max",
|
||||
)
|
||||
return Response(max_asn + 1)
|
||||
|
||||
|
||||
class LogViewSet(ViewSet):
|
||||
|
Reference in New Issue
Block a user