Add 'barcode_hash' data to more API serializers: (#3906)

* Add 'barcode_hash' data to more API serializers:

- part
- stock location
- supplier part

* Bump API version

* Make 'barcode_hash' fields read-only via the API

* Fix for Part serializer
This commit is contained in:
Oliver 2022-11-07 22:36:15 +11:00 committed by GitHub
parent 0c0e61432d
commit 92260f2059
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 1 deletions

View File

@ -2,11 +2,16 @@
# InvenTree API version # InvenTree API version
INVENTREE_API_VERSION = 79 INVENTREE_API_VERSION = 80
""" """
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
v80 -> 2022-11-07 : https://github.com/inventree/InvenTree/pull/3906
- Adds 'barcode_hash' to Part API serializer
- Adds 'barcode_hash' to StockLocation API serializer
- Adds 'barcode_hash' to SupplierPart API serializer
v79 -> 2022-11-03 : https://github.com/inventree/InvenTree/pull/3895 v79 -> 2022-11-03 : https://github.com/inventree/InvenTree/pull/3895
- Add metadata to Company - Add metadata to Company

View File

@ -294,6 +294,7 @@ class SupplierPartSerializer(InvenTreeModelSerializer):
'MPN', 'MPN',
'note', 'note',
'pk', 'pk',
'barcode_hash',
'packaging', 'packaging',
'pack_size', 'pack_size',
'part', 'part',
@ -307,6 +308,7 @@ class SupplierPartSerializer(InvenTreeModelSerializer):
read_only_fields = [ read_only_fields = [
'availability_updated', 'availability_updated',
'barcode_hash',
] ]
@staticmethod @staticmethod

View File

@ -285,6 +285,7 @@ class PartBriefSerializer(InvenTreeModelSerializer):
fields = [ fields = [
'pk', 'pk',
'IPN', 'IPN',
'barcode_hash',
'default_location', 'default_location',
'name', 'name',
'revision', 'revision',
@ -301,6 +302,10 @@ class PartBriefSerializer(InvenTreeModelSerializer):
'units', 'units',
] ]
read_only_fields = [
'barcode_hash',
]
class PartSerializer(RemoteImageMixin, InvenTreeModelSerializer): class PartSerializer(RemoteImageMixin, InvenTreeModelSerializer):
"""Serializer for complete detail information of a part. """Serializer for complete detail information of a part.
@ -430,6 +435,7 @@ class PartSerializer(RemoteImageMixin, InvenTreeModelSerializer):
'allocated_to_build_orders', 'allocated_to_build_orders',
'allocated_to_sales_orders', 'allocated_to_sales_orders',
'assembly', 'assembly',
'barcode_hash',
'category', 'category',
'category_detail', 'category_detail',
'component', 'component',
@ -467,6 +473,10 @@ class PartSerializer(RemoteImageMixin, InvenTreeModelSerializer):
'virtual', 'virtual',
] ]
read_only_fields = [
'barcode_hash',
]
def save(self): def save(self):
"""Save the Part instance""" """Save the Part instance"""

View File

@ -65,6 +65,10 @@ class StockItemSerializerBrief(InvenTree.serializers.InvenTreeModelSerializer):
'barcode_hash', 'barcode_hash',
] ]
read_only_fields = [
'barcode_hash',
]
def validate_serial(self, value): def validate_serial(self, value):
"""Make sure serial is not to big.""" """Make sure serial is not to big."""
if abs(extract_int(value)) > 0x7fffffff: if abs(extract_int(value)) > 0x7fffffff:
@ -258,6 +262,7 @@ class StockItemSerializer(InvenTree.serializers.InvenTreeModelSerializer):
""" """
read_only_fields = [ read_only_fields = [
'allocated', 'allocated',
'barcode_hash',
'stocktake_date', 'stocktake_date',
'stocktake_user', 'stocktake_user',
'updated', 'updated',
@ -602,6 +607,7 @@ class LocationSerializer(InvenTree.serializers.InvenTreeModelSerializer):
model = StockLocation model = StockLocation
fields = [ fields = [
'pk', 'pk',
'barcode_hash',
'url', 'url',
'name', 'name',
'level', 'level',
@ -613,6 +619,10 @@ class LocationSerializer(InvenTree.serializers.InvenTreeModelSerializer):
'icon', 'icon',
] ]
read_only_fields = [
'barcode_hash',
]
class StockItemAttachmentSerializer(InvenTree.serializers.InvenTreeAttachmentSerializer): class StockItemAttachmentSerializer(InvenTree.serializers.InvenTreeAttachmentSerializer):
"""Serializer for StockItemAttachment model.""" """Serializer for StockItemAttachment model."""