From 904e056f317d5f6c10db76cd6a371174df679c93 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Oct 2024 05:13:50 +0000 Subject: [PATCH 1/4] Revert change to BuildItem API - Requires "allocations" for build output table - Probably can refactor this later --- src/backend/InvenTree/build/serializers.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/InvenTree/build/serializers.py b/src/backend/InvenTree/build/serializers.py index 583b620f5be..dffa9e004fa 100644 --- a/src/backend/InvenTree/build/serializers.py +++ b/src/backend/InvenTree/build/serializers.py @@ -1307,6 +1307,9 @@ class Meta: 'available_variant_stock', 'external_stock', + # Related fields + 'allocations', + # Extra fields only for data export 'part_description', 'part_category_name', @@ -1330,6 +1333,8 @@ class Meta: part_category_id = serializers.PrimaryKeyRelatedField(source='bom_item.sub_part.category', label=_('Part Category ID'), read_only=True) part_category_name = serializers.CharField(source='bom_item.sub_part.category.name', label=_('Part Category Name'), read_only=True) + allocations = BuildItemSerializer(many=True, read_only=True) + # BOM item info fields reference = serializers.CharField(source='bom_item.reference', label=_('Reference'), read_only=True) consumable = serializers.BooleanField(source='bom_item.consumable', label=_('Consumable'), read_only=True) @@ -1403,6 +1408,8 @@ def annotate_queryset(queryset, build=None): # Pre-fetch related fields queryset = queryset.prefetch_related( 'allocations', + 'allocations__stock_item', + 'allocations__stock_item__location', 'bom_item__sub_part__stock_items', 'bom_item__sub_part__stock_items__allocations', From b53cbdb76b8b29490456289e7f6a84bc4bd7832b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Oct 2024 05:26:37 +0000 Subject: [PATCH 2/4] Bug fix for BuildOutputTable in PUI - Correct calculation for "fully allocated" --- src/frontend/src/tables/build/BuildOutputTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/tables/build/BuildOutputTable.tsx b/src/frontend/src/tables/build/BuildOutputTable.tsx index fbea651f5d4..a377b0a741f 100644 --- a/src/frontend/src/tables/build/BuildOutputTable.tsx +++ b/src/frontend/src/tables/build/BuildOutputTable.tsx @@ -153,7 +153,7 @@ export default function BuildOutputTable({ // Find all allocations which match the build output let allocations = item.allocations.filter( - (allocation: any) => (allocation.install_into = record.pk) + (allocation: any) => allocation.install_into == record.pk ); allocations.forEach((allocation: any) => { From 6de7638260ea0de728e0e2d71fb4ed2fe4cab386 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Oct 2024 05:28:06 +0000 Subject: [PATCH 3/4] Adjust annotations for serializer --- src/backend/InvenTree/build/serializers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/InvenTree/build/serializers.py b/src/backend/InvenTree/build/serializers.py index dffa9e004fa..c7f8de18359 100644 --- a/src/backend/InvenTree/build/serializers.py +++ b/src/backend/InvenTree/build/serializers.py @@ -1409,6 +1409,7 @@ def annotate_queryset(queryset, build=None): queryset = queryset.prefetch_related( 'allocations', 'allocations__stock_item', + 'allocations__stock_item__part', 'allocations__stock_item__location', 'bom_item__sub_part__stock_items', From 2497411d14c9a5488d16f3306546d1e6578065ea Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Oct 2024 05:38:52 +0000 Subject: [PATCH 4/4] Bump API version --- src/backend/InvenTree/InvenTree/api_version.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index be705504810..db586544e48 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,13 +1,16 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 272 +INVENTREE_API_VERSION = 273 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v273 - 2024-10-28 : https://github.com/inventree/InvenTree/pull/8376 + - Fixes for the BuildLine API endpoint + v272 - 2024-10-25 : https://github.com/inventree/InvenTree/pull/8343 - Adjustments to BuildLine API serializers