mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-20 02:15:53 +00:00
API for stock app
This commit is contained in:
52
InvenTree/stock/serializers.py
Normal file
52
InvenTree/stock/serializers.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from .models import StockItem, StockLocation
|
||||
|
||||
|
||||
class StockItemSerializer(serializers.ModelSerializer):
|
||||
""" Serializer for a StockItem
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = StockItem
|
||||
fields = ('pk',
|
||||
'part',
|
||||
'location',
|
||||
'quantity',
|
||||
'status',
|
||||
'updated',
|
||||
'last_checked',
|
||||
'review_needed',
|
||||
'expected_arrival')
|
||||
|
||||
|
||||
class LocationBriefSerializer(serializers.ModelSerializer):
|
||||
""" Brief information about a stock location
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = StockLocation
|
||||
fields = ('pk',
|
||||
'name',
|
||||
'description')
|
||||
|
||||
|
||||
class LocationDetailSerializer(serializers.ModelSerializer):
|
||||
""" Detailed information about a stock location
|
||||
"""
|
||||
|
||||
# List of all stock items in this location
|
||||
items = StockItemSerializer(many=True)
|
||||
|
||||
# List of all child locations under this one
|
||||
children = LocationBriefSerializer(many=True)
|
||||
|
||||
class Meta:
|
||||
model = StockLocation
|
||||
fields = ('pk',
|
||||
'name',
|
||||
'description',
|
||||
'parent',
|
||||
'path',
|
||||
'children',
|
||||
'items')
|
Reference in New Issue
Block a user