mirror of
https://github.com/inventree/InvenTree.git
synced 2026-02-06 13:25:53 +00:00
Patch Sales Order line items progress bar to count fully allocated line items (#11102)
* Added "allocated_lines" to the backend and frontend tables * Remove incorrectly added UI panels from Sales Order Detail * bump api version --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
"""InvenTree API version information."""
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 444
|
||||
INVENTREE_API_VERSION = 445
|
||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||
|
||||
INVENTREE_API_TEXT = """
|
||||
|
||||
v445 -> 2026-01-29 : https://github.com/inventree/InvenTree/pull/11102
|
||||
- Added "allocated_lines" field to SalesOrderSerializer to track fully allocated line items
|
||||
|
||||
v444 -> 2026-01-27 : https://github.com/inventree/InvenTree/pull/11208
|
||||
- Add customize option to disable theme loading from user profile (mainly for demo site use)
|
||||
|
||||
|
||||
@@ -1025,6 +1025,7 @@ class SalesOrderSerializer(
|
||||
'order_currency',
|
||||
'shipments_count',
|
||||
'completed_shipments_count',
|
||||
'allocated_lines',
|
||||
])
|
||||
read_only_fields = ['status', 'creation_date', 'shipment_date']
|
||||
extra_kwargs = {'order_currency': {'required': False}}
|
||||
@@ -1040,6 +1041,7 @@ class SalesOrderSerializer(
|
||||
"""Add extra information to the queryset.
|
||||
|
||||
- Number of line items in the SalesOrder
|
||||
- Number of fully allocated line items
|
||||
- Number of completed line items in the SalesOrder
|
||||
- Overdue status of the SalesOrder
|
||||
"""
|
||||
@@ -1049,6 +1051,19 @@ class SalesOrderSerializer(
|
||||
completed_lines=SubqueryCount('lines', filter=Q(quantity__lte=F('shipped')))
|
||||
)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
allocated_lines=SubqueryCount(
|
||||
'lines',
|
||||
filter=Q(part__virtual=True)
|
||||
| Q(shipped__gte=F('quantity'))
|
||||
| Q(
|
||||
quantity__lte=Coalesce(
|
||||
SubquerySum('allocations__quantity'), Decimal(0)
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
queryset = queryset.annotate(
|
||||
overdue=Case(
|
||||
When(
|
||||
@@ -1084,6 +1099,10 @@ class SalesOrderSerializer(
|
||||
read_only=True, allow_null=True, label=_('Completed Shipments')
|
||||
)
|
||||
|
||||
allocated_lines = serializers.IntegerField(
|
||||
read_only=True, allow_null=True, label=_('Allocated Lines')
|
||||
)
|
||||
|
||||
|
||||
class SalesOrderIssueSerializer(OrderAdjustSerializer):
|
||||
"""Serializer for issuing a SalesOrder."""
|
||||
|
||||
Reference in New Issue
Block a user