2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-01 13:06:45 +00:00

[Bug] Fix issue with build order lines table (#8376)

* Revert change to BuildItem API

- Requires "allocations" for build output table
- Probably can refactor this later

* Bug fix for BuildOutputTable in PUI

- Correct calculation for "fully allocated"

* Adjust annotations for serializer

* Bump API version
This commit is contained in:
Oliver 2024-10-28 17:06:09 +11:00 committed by GitHub
parent 21ab1a184d
commit 6953640161
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 2 deletions

View File

@ -1,13 +1,16 @@
"""InvenTree API version information.""" """InvenTree API version information."""
# InvenTree API version # 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.""" """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 = """
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 v272 - 2024-10-25 : https://github.com/inventree/InvenTree/pull/8343
- Adjustments to BuildLine API serializers - Adjustments to BuildLine API serializers

View File

@ -1307,6 +1307,9 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
'available_variant_stock', 'available_variant_stock',
'external_stock', 'external_stock',
# Related fields
'allocations',
# Extra fields only for data export # Extra fields only for data export
'part_description', 'part_description',
'part_category_name', 'part_category_name',
@ -1330,6 +1333,8 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
part_category_id = serializers.PrimaryKeyRelatedField(source='bom_item.sub_part.category', label=_('Part Category ID'), read_only=True) 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) 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 # BOM item info fields
reference = serializers.CharField(source='bom_item.reference', label=_('Reference'), read_only=True) reference = serializers.CharField(source='bom_item.reference', label=_('Reference'), read_only=True)
consumable = serializers.BooleanField(source='bom_item.consumable', label=_('Consumable'), read_only=True) consumable = serializers.BooleanField(source='bom_item.consumable', label=_('Consumable'), read_only=True)
@ -1403,6 +1408,9 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
# Pre-fetch related fields # Pre-fetch related fields
queryset = queryset.prefetch_related( queryset = queryset.prefetch_related(
'allocations', 'allocations',
'allocations__stock_item',
'allocations__stock_item__part',
'allocations__stock_item__location',
'bom_item__sub_part__stock_items', 'bom_item__sub_part__stock_items',
'bom_item__sub_part__stock_items__allocations', 'bom_item__sub_part__stock_items__allocations',

View File

@ -153,7 +153,7 @@ export default function BuildOutputTable({
// Find all allocations which match the build output // Find all allocations which match the build output
let allocations = item.allocations.filter( let allocations = item.allocations.filter(
(allocation: any) => (allocation.install_into = record.pk) (allocation: any) => allocation.install_into == record.pk
); );
allocations.forEach((allocation: any) => { allocations.forEach((allocation: any) => {