mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge branch 'stock-endpoint'
This commit is contained in:
commit
c906cbe2c2
@ -7,10 +7,12 @@ from rest_framework import serializers
|
|||||||
from .models import Company
|
from .models import Company
|
||||||
from .models import SupplierPart, SupplierPriceBreak
|
from .models import SupplierPart, SupplierPriceBreak
|
||||||
|
|
||||||
|
from InvenTree.serializers import InvenTreeModelSerializer
|
||||||
|
|
||||||
from part.serializers import PartBriefSerializer
|
from part.serializers import PartBriefSerializer
|
||||||
|
|
||||||
|
|
||||||
class CompanyBriefSerializer(serializers.ModelSerializer):
|
class CompanyBriefSerializer(InvenTreeModelSerializer):
|
||||||
""" Serializer for Company object (limited detail) """
|
""" Serializer for Company object (limited detail) """
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
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) """
|
""" Serializer for Company object (full detail) """
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
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 """
|
""" Serializer for SupplierPart object """
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
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 """
|
""" Serializer for SupplierPriceBreak object """
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -12,7 +12,7 @@ from .models import BomItem
|
|||||||
from InvenTree.serializers import InvenTreeModelSerializer
|
from InvenTree.serializers import InvenTreeModelSerializer
|
||||||
|
|
||||||
|
|
||||||
class CategorySerializer(serializers.ModelSerializer):
|
class CategorySerializer(InvenTreeModelSerializer):
|
||||||
""" Serializer for PartCategory """
|
""" Serializer for PartCategory """
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
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) """
|
""" Serializer for Part (brief detail) """
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
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.
|
""" Serializer for complete detail information of a part.
|
||||||
Used when displaying all details of a single component.
|
Used when displaying all details of a single component.
|
||||||
"""
|
"""
|
||||||
|
@ -142,6 +142,8 @@ class StockItem(models.Model):
|
|||||||
- Quantity must be 1 if the StockItem has a serial number
|
- 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!
|
# The 'supplier_part' field must point to the same part!
|
||||||
try:
|
try:
|
||||||
if self.supplier_part is not None:
|
if self.supplier_part is not None:
|
||||||
|
@ -8,10 +8,10 @@ from .models import StockItem, StockLocation
|
|||||||
from .models import StockItemTracking
|
from .models import StockItemTracking
|
||||||
|
|
||||||
from part.serializers import PartBriefSerializer
|
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
|
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 """
|
""" Brief serializers for a StockItem """
|
||||||
|
|
||||||
location_name = serializers.CharField(source='location', read_only=True)
|
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:
|
""" Serializer for a StockItem:
|
||||||
|
|
||||||
- Includes serialization for the linked part
|
- Includes serialization for the linked part
|
||||||
@ -102,19 +102,18 @@ class StockItemSerializer(serializers.ModelSerializer):
|
|||||||
'stocktake_date',
|
'stocktake_date',
|
||||||
'stocktake_user',
|
'stocktake_user',
|
||||||
'updated',
|
'updated',
|
||||||
'quantity',
|
|
||||||
'in_stock'
|
'in_stock'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class StockQuantitySerializer(serializers.ModelSerializer):
|
class StockQuantitySerializer(InvenTreeModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockItem
|
model = StockItem
|
||||||
fields = ('quantity',)
|
fields = ('quantity',)
|
||||||
|
|
||||||
|
|
||||||
class LocationSerializer(serializers.ModelSerializer):
|
class LocationSerializer(InvenTreeModelSerializer):
|
||||||
""" Detailed information about a stock location
|
""" 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 """
|
""" Serializer for StockItemTracking model """
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user