Merge branch 'stock-endpoint'

This commit is contained in:
Oliver Walters 2019-06-13 23:06:08 +10:00
commit c906cbe2c2
4 changed files with 18 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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