2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 20:45:44 +00:00

Created by (#8848)

* Add 'created_by' field to order API endpoints

* Add 'created_by' filter

* Allow ordering by 'created_by' field

* Update UI tables

- Show "Created By" column
- Column sorting
- Column filtering

* Cleanup order detail pages

* Bump API version

* Refactor table filters

* Fix BuildOrderTable filters
This commit is contained in:
Oliver
2025-01-08 10:07:38 +11:00
committed by GitHub
parent 296c54a1d7
commit 9138e31e58
12 changed files with 185 additions and 114 deletions

View File

@ -1,13 +1,18 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 297
INVENTREE_API_VERSION = 298
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v298 - 2025-01-07 - https://github.com/inventree/InvenTree/pull/8848
- Adds 'created_by' field to PurchaseOrder API endpoints
- Adds 'created_by' field to SalesOrder API endpoints
- Adds 'created_by' field to ReturnOrder API endpoints
v297 - 2024-12-29 - https://github.com/inventree/InvenTree/pull/8438
- Adjustments to the CustomUserState API endpoints and serializers

View File

@ -5,6 +5,7 @@ from typing import cast
from django.conf import settings
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from django.db.models import F, Q
from django.http.response import JsonResponse
from django.urls import include, path, re_path
@ -168,6 +169,10 @@ class OrderFilter(rest_filters.FilterSet):
queryset=Owner.objects.all(), field_name='responsible', label=_('Responsible')
)
created_by = rest_filters.ModelChoiceFilter(
queryset=User.objects.all(), field_name='created_by', label=_('Created By')
)
created_before = InvenTreeDateFilter(
label=_('Created Before'), field_name='creation_date', lookup_expr='lt'
)
@ -328,6 +333,7 @@ class PurchaseOrderList(
ordering_fields = [
'creation_date',
'created_by',
'reference',
'supplier__name',
'target_date',
@ -785,6 +791,7 @@ class SalesOrderList(
ordering_fields = [
'creation_date',
'created_by',
'reference',
'customer__name',
'customer_reference',
@ -1369,6 +1376,7 @@ class ReturnOrderList(
ordering_fields = [
'creation_date',
'created_by',
'reference',
'customer__name',
'customer_reference',

View File

@ -50,6 +50,7 @@ from InvenTree.serializers import (
InvenTreeModelSerializer,
InvenTreeMoneySerializer,
NotesFieldMixin,
UserSerializer,
)
from order.status_codes import (
PurchaseOrderStatusGroups,
@ -158,6 +159,8 @@ class AbstractOrderSerializer(DataImportExportSerializerMixin, serializers.Seria
required=False, allow_null=True, label=_('Creation Date')
)
created_by = UserSerializer(read_only=True)
duplicate = DuplicateOrderSerializer(
label=_('Duplicate Order'),
help_text=_('Specify options for duplicating this order'),
@ -174,6 +177,7 @@ class AbstractOrderSerializer(DataImportExportSerializerMixin, serializers.Seria
def annotate_queryset(queryset):
"""Add extra information to the queryset."""
queryset = queryset.annotate(line_items=SubqueryCount('lines'))
queryset = queryset.select_related('created_by')
return queryset
@ -183,6 +187,7 @@ class AbstractOrderSerializer(DataImportExportSerializerMixin, serializers.Seria
return [
'pk',
'creation_date',
'created_by',
'target_date',
'description',
'line_items',