2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Implement a generic API endpoint for enumeration of status codes (#4543)

* Implement a generic API endpoint for enumeration of status codes

* Adds endpoint for PurchaseOrderStatus

* Add more endpoints (sales order / return orer)

* Add endpoints for StockStatus and StockTrackingCode

* Support build status

* Use the attribute name as the dict key

* Refactored status codes in javascript

- Now accessible by "name" (instead of integer key)
- Will make javascript code much more readable

* Bump API version
This commit is contained in:
Oliver
2023-03-31 07:27:24 +11:00
committed by GitHub
parent f4f7803e96
commit 327ecf2156
9 changed files with 189 additions and 61 deletions

View File

@ -23,13 +23,14 @@ from build.models import Build
from company.models import Company, SupplierPart
from company.serializers import CompanySerializer, SupplierPartSerializer
from InvenTree.api import (APIDownloadMixin, AttachmentMixin,
ListCreateDestroyAPIView)
ListCreateDestroyAPIView, StatusView)
from InvenTree.filters import InvenTreeOrderingFilter
from InvenTree.helpers import (DownloadFile, extract_serial_numbers, isNull,
str2bool, str2int)
from InvenTree.mixins import (CreateAPI, CustomRetrieveUpdateDestroyAPI,
ListAPI, ListCreateAPI, RetrieveAPI,
RetrieveUpdateAPI, RetrieveUpdateDestroyAPI)
from InvenTree.status_codes import StockHistoryCode, StockStatus
from order.models import (PurchaseOrder, ReturnOrder, SalesOrder,
SalesOrderAllocation)
from order.serializers import (PurchaseOrderSerializer, ReturnOrderSerializer,
@ -1421,6 +1422,10 @@ stock_api_urls = [
# StockItemTracking API endpoints
re_path(r'^track/', include([
path(r'<int:pk>/', StockTrackingDetail.as_view(), name='api-stock-tracking-detail'),
# Stock tracking status code information
re_path(r'status/', StatusView.as_view(), {StatusView.MODEL_REF: StockHistoryCode}, name='api-stock-tracking-status-codes'),
re_path(r'^.*$', StockTrackingList.as_view(), name='api-stock-tracking-list'),
])),
@ -1435,6 +1440,9 @@ stock_api_urls = [
re_path(r'^.*$', StockDetail.as_view(), name='api-stock-detail'),
])),
# Stock item status code information
re_path(r'status/', StatusView.as_view(), {StatusView.MODEL_REF: StockStatus}, name='api-stock-status-codes'),
# Anything else
re_path(r'^.*$', StockList.as_view(), name='api-stock-list'),
]