diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index 185312b5eb..419763fce0 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,12 +1,15 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 214 +INVENTREE_API_VERSION = 215 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v215 - 2024-07-09 : https://github.com/inventree/InvenTree/pull/7591 + - Adds additional fields to the BuildLine serializer + v214 - 2024-07-08 : https://github.com/inventree/InvenTree/pull/7587 - Adds "default_location_detail" field to the Part API diff --git a/src/backend/InvenTree/build/serializers.py b/src/backend/InvenTree/build/serializers.py index 3efd581bbf..873370023b 100644 --- a/src/backend/InvenTree/build/serializers.py +++ b/src/backend/InvenTree/build/serializers.py @@ -1139,6 +1139,11 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali 'allocations', ] + export_only_fields = [ + 'part_description', + 'part_category_name', + ] + class Meta: """Serializer metaclass""" @@ -1157,11 +1162,14 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali 'consumable', 'optional', 'trackable', + 'inherited', + 'allow_variants', # Part detail fields 'part', 'part_name', 'part_IPN', + 'part_category_id', # Annotated fields 'allocated', @@ -1172,6 +1180,10 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali 'available_variant_stock', 'total_available_stock', 'external_stock', + + # Extra fields only for data export + 'part_description', + 'part_category_name', ] read_only_fields = [ @@ -1185,11 +1197,17 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali part_name = serializers.CharField(source='bom_item.sub_part.name', label=_('Part Name'), read_only=True) part_IPN = serializers.CharField(source='bom_item.sub_part.IPN', label=_('Part IPN'), read_only=True) + part_description = serializers.CharField(source='bom_item.sub_part.description', label=_('Part Description'), 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) + # 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) optional = serializers.BooleanField(source='bom_item.optional', label=_('Optional'), read_only=True) trackable = serializers.BooleanField(source='bom_item.sub_part.trackable', label=_('Trackable'), read_only=True) + inherited = serializers.BooleanField(source='bom_item.inherited', label=_('Inherited'), read_only=True) + allow_variants = serializers.BooleanField(source='bom_item.allow_variants', label=_('Allow Variants'), read_only=True) quantity = serializers.FloatField(label=_('Quantity')) diff --git a/src/backend/InvenTree/templates/js/translated/build.js b/src/backend/InvenTree/templates/js/translated/build.js index 360b430cf3..5a762d2bd5 100644 --- a/src/backend/InvenTree/templates/js/translated/build.js +++ b/src/backend/InvenTree/templates/js/translated/build.js @@ -2516,6 +2516,15 @@ function loadBuildLineTable(table, build_id, options={}) { return row.bom_item_detail.reference; } }, + { + field: 'optional', + title: '{% trans "Optional" %}', + sortable: true, + switchable: true, + formatter: function(value, row) { + return yesNoLabel(row.bom_item_detail.optional); + } + }, { field: 'consumable', title: '{% trans "Consumable" %}', @@ -2526,12 +2535,21 @@ function loadBuildLineTable(table, build_id, options={}) { } }, { - field: 'optional', - title: '{% trans "Optional" %}', - sortable: true, + field: 'allow_variants', + title: '{% trans "Allow Variants" %}', + sortable: false, switchable: true, formatter: function(value, row) { - return yesNoLabel(row.bom_item_detail.optional); + return yesNoLabel(row.bom_item_detail.allow_variants); + } + }, + { + field: 'inherited', + title: '{% trans "Gets Inherited" %}', + sortable: false, + switchable: true, + formatter: function(value, row) { + return yesNoLabel(row.bom_item_detail.inherited); } }, { diff --git a/src/frontend/src/tables/build/BuildLineTable.tsx b/src/frontend/src/tables/build/BuildLineTable.tsx index 6daef80c99..90ee524b51 100644 --- a/src/frontend/src/tables/build/BuildLineTable.tsx +++ b/src/frontend/src/tables/build/BuildLineTable.tsx @@ -139,13 +139,22 @@ export default function BuildLineTable({ params = {} }: { params?: any }) { sortable: true, title: t`Reference` }, + BooleanColumn({ + accessor: 'bom_item_detail.optional', + ordering: 'optional' + }), BooleanColumn({ accessor: 'bom_item_detail.consumable', ordering: 'consumable' }), BooleanColumn({ - accessor: 'bom_item_detail.optional', - ordering: 'optional' + accessor: 'bom_item_detail.allow_variants', + ordering: 'allow_variants' + }), + BooleanColumn({ + accessor: 'bom_item_detail.inherited', + ordering: 'inherited', + title: t`Gets Inherited` }), BooleanColumn({ accessor: 'part_detail.trackable',