2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-23 20:05:53 +00:00
Files
InvenTree/InvenTree/stock/serializers.py
Oliver Walters 7478371d0c Added stockhistory
using django-simple-history
2017-04-21 23:47:04 +10:00

52 lines
1.3 KiB
Python

from rest_framework import serializers
from .models import StockItem, StockLocation
class StockItemSerializer(serializers.HyperlinkedModelSerializer):
""" Serializer for a StockItem
"""
class Meta:
model = StockItem
fields = ('url',
'part',
'supplier_part',
'location',
'quantity',
'status',
'notes',
'updated',
'stocktake_date',
'stocktake_user',
'review_needed',
'expected_arrival')
""" These fields are read-only in this context.
They can be updated by accessing the appropriate API endpoints
"""
read_only_fields = ('stocktake_date',
'stocktake_user',
'updated',
'quantity',)
class StockQuantitySerializer(serializers.ModelSerializer):
class Meta:
model = StockItem
fields = ('quantity',)
class LocationSerializer(serializers.HyperlinkedModelSerializer):
""" Detailed information about a stock location
"""
class Meta:
model = StockLocation
fields = ('url',
'name',
'description',
'parent',
'path')