2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-07 06:00:57 +00:00

Allocation search by IPN (#9944)

* Fix for "has_ipn" filter

* Enable filtering and sorting by IPN in SalesOrderAllocation table

* Bump API version
This commit is contained in:
Oliver
2025-07-03 16:53:46 +10:00
committed by GitHub
parent d9f71ca20f
commit 4307e6d170
4 changed files with 17 additions and 5 deletions

View File

@ -1,12 +1,16 @@
"""InvenTree API version information.""" """InvenTree API version information."""
# InvenTree API version # InvenTree API version
INVENTREE_API_VERSION = 360 INVENTREE_API_VERSION = 361
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" """Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """ INVENTREE_API_TEXT = """
v361 -> 2025-07-03 : https://github.com/inventree/InvenTree/pull/9944
- Enable SalesOrderAllocation list to be filtered by part IPN value
- Enable SalesOrderAllocation list to be ordered by part MPN value
v360 -> 2025-07-02 : https://github.com/inventree/InvenTree/pull/9937 v360 -> 2025-07-02 : https://github.com/inventree/InvenTree/pull/9937
- Provide more detailed StockItem information in the BuildItem serializer - Provide more detailed StockItem information in the BuildItem serializer
- Provide more detailed StockItem information in the SalesOrderAllocation serializer - Provide more detailed StockItem information in the SalesOrderAllocation serializer

View File

@ -1217,6 +1217,7 @@ class SalesOrderAllocationList(SalesOrderAllocationMixin, BulkUpdateMixin, ListA
'quantity', 'quantity',
'part', 'part',
'serial', 'serial',
'IPN',
'batch', 'batch',
'location', 'location',
'order', 'order',
@ -1224,6 +1225,7 @@ class SalesOrderAllocationList(SalesOrderAllocationMixin, BulkUpdateMixin, ListA
] ]
ordering_field_aliases = { ordering_field_aliases = {
'IPN': 'item__part__IPN',
'part': 'item__part__name', 'part': 'item__part__name',
'serial': ['item__serial_int', 'item__serial'], 'serial': ['item__serial_int', 'item__serial'],
'batch': 'item__batch', 'batch': 'item__batch',
@ -1232,7 +1234,12 @@ class SalesOrderAllocationList(SalesOrderAllocationMixin, BulkUpdateMixin, ListA
'shipment_date': 'shipment__shipment_date', 'shipment_date': 'shipment__shipment_date',
} }
search_fields = {'item__part__name', 'item__serial', 'item__batch'} search_fields = {
'item__part__name',
'item__part__IPN',
'item__serial',
'item__batch',
}
def get_serializer(self, *args, **kwargs): def get_serializer(self, *args, **kwargs):
"""Return the serializer instance for this endpoint. """Return the serializer instance for this endpoint.

View File

@ -716,8 +716,8 @@ class PartFilter(rest_filters.FilterSet):
def filter_has_ipn(self, queryset, name, value): def filter_has_ipn(self, queryset, name, value):
"""Filter by whether the Part has an IPN (internal part number) or not.""" """Filter by whether the Part has an IPN (internal part number) or not."""
if str2bool(value): if str2bool(value):
return queryset.exclude(IPN='') return queryset.exclude(IPN='').exclude(IPN=None)
return queryset.filter(IPN='') return queryset.filter(Q(IPN='') | Q(IPN=None)).distinct()
# Regex filter for name # Regex filter for name
name_regex = rest_filters.CharFilter( name_regex = rest_filters.CharFilter(

View File

@ -134,7 +134,8 @@ export default function SalesOrderAllocationTable({
accessor: 'part_detail.IPN', accessor: 'part_detail.IPN',
title: t`IPN`, title: t`IPN`,
hidden: showPartInfo != true, hidden: showPartInfo != true,
sortable: false sortable: true,
ordering: 'IPN'
}, },
{ {
accessor: 'serial', accessor: 'serial',