Build Line Updates (#7591)

* Update build line tables

* Add additional fiels to BuildLine serializer

* Bump API version
This commit is contained in:
Oliver 2024-07-09 13:35:32 +10:00 committed by GitHub
parent c05cf86c8e
commit e943c5a686
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 55 additions and 7 deletions

View File

@ -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

View File

@ -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'))

View File

@ -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);
}
},
{

View File

@ -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',