diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py index 773e033b7f..77a4bddbf3 100644 --- a/InvenTree/company/serializers.py +++ b/InvenTree/company/serializers.py @@ -7,10 +7,12 @@ from rest_framework import serializers from .models import Company from .models import SupplierPart, SupplierPriceBreak +from InvenTree.serializers import InvenTreeModelSerializer + from part.serializers import PartBriefSerializer -class CompanyBriefSerializer(serializers.ModelSerializer): +class CompanyBriefSerializer(InvenTreeModelSerializer): """ Serializer for Company object (limited detail) """ url = serializers.CharField(source='get_absolute_url', read_only=True) @@ -24,7 +26,7 @@ class CompanyBriefSerializer(serializers.ModelSerializer): ] -class CompanySerializer(serializers.ModelSerializer): +class CompanySerializer(InvenTreeModelSerializer): """ Serializer for Company object (full detail) """ url = serializers.CharField(source='get_absolute_url', read_only=True) @@ -52,7 +54,7 @@ class CompanySerializer(serializers.ModelSerializer): ] -class SupplierPartSerializer(serializers.ModelSerializer): +class SupplierPartSerializer(InvenTreeModelSerializer): """ Serializer for SupplierPart object """ url = serializers.CharField(source='get_absolute_url', read_only=True) @@ -92,7 +94,7 @@ class SupplierPartSerializer(serializers.ModelSerializer): ] -class SupplierPriceBreakSerializer(serializers.ModelSerializer): +class SupplierPriceBreakSerializer(InvenTreeModelSerializer): """ Serializer for SupplierPriceBreak object """ class Meta: diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 37f5f1db7a..36be5de6db 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -12,7 +12,7 @@ from .models import BomItem from InvenTree.serializers import InvenTreeModelSerializer -class CategorySerializer(serializers.ModelSerializer): +class CategorySerializer(InvenTreeModelSerializer): """ Serializer for PartCategory """ url = serializers.CharField(source='get_absolute_url', read_only=True) @@ -29,7 +29,7 @@ class CategorySerializer(serializers.ModelSerializer): ] -class PartBriefSerializer(serializers.ModelSerializer): +class PartBriefSerializer(InvenTreeModelSerializer): """ Serializer for Part (brief detail) """ url = serializers.CharField(source='get_absolute_url', read_only=True) @@ -56,7 +56,7 @@ class PartBriefSerializer(serializers.ModelSerializer): ] -class PartSerializer(serializers.ModelSerializer): +class PartSerializer(InvenTreeModelSerializer): """ Serializer for complete detail information of a part. Used when displaying all details of a single component. """ diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index b9773f9d77..50a0f39e72 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -142,6 +142,8 @@ class StockItem(models.Model): - Quantity must be 1 if the StockItem has a serial number """ + print("Trying to clean the StockItem") + # The 'supplier_part' field must point to the same part! try: if self.supplier_part is not None: diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 21f2ef4e9e..4ec0530bf4 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -8,10 +8,10 @@ from .models import StockItem, StockLocation from .models import StockItemTracking from part.serializers import PartBriefSerializer -from InvenTree.serializers import UserSerializerBrief +from InvenTree.serializers import UserSerializerBrief, InvenTreeModelSerializer -class LocationBriefSerializer(serializers.ModelSerializer): +class LocationBriefSerializer(InvenTreeModelSerializer): """ Provides a brief serializer for a StockLocation object """ @@ -28,7 +28,7 @@ class LocationBriefSerializer(serializers.ModelSerializer): ] -class StockItemSerializerBrief(serializers.ModelSerializer): +class StockItemSerializerBrief(InvenTreeModelSerializer): """ Brief serializers for a StockItem """ location_name = serializers.CharField(source='location', read_only=True) @@ -47,7 +47,7 @@ class StockItemSerializerBrief(serializers.ModelSerializer): ] -class StockItemSerializer(serializers.ModelSerializer): +class StockItemSerializer(InvenTreeModelSerializer): """ Serializer for a StockItem: - Includes serialization for the linked part @@ -102,19 +102,18 @@ class StockItemSerializer(serializers.ModelSerializer): 'stocktake_date', 'stocktake_user', 'updated', - 'quantity', 'in_stock' ] -class StockQuantitySerializer(serializers.ModelSerializer): +class StockQuantitySerializer(InvenTreeModelSerializer): class Meta: model = StockItem fields = ('quantity',) -class LocationSerializer(serializers.ModelSerializer): +class LocationSerializer(InvenTreeModelSerializer): """ Detailed information about a stock location """ @@ -132,7 +131,7 @@ class LocationSerializer(serializers.ModelSerializer): ] -class StockTrackingSerializer(serializers.ModelSerializer): +class StockTrackingSerializer(InvenTreeModelSerializer): """ Serializer for StockItemTracking model """ url = serializers.CharField(source='get_absolute_url', read_only=True)