2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Simplify StockItem serializer

- Some more work needed here to cut down on database hits
This commit is contained in:
Oliver Walters
2020-04-20 01:09:37 +10:00
parent 4b1b9df193
commit 0334035e77
3 changed files with 1 additions and 18 deletions

View File

@ -77,13 +77,11 @@ class StockItemSerializer(InvenTreeModelSerializer):
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
location_detail = LocationBriefSerializer(source='location', many=False, read_only=True)
supplier_part_detail = SupplierPartSerializer(source='supplier_part', many=False, read_only=True)
def __init__(self, *args, **kwargs):
part_detail = kwargs.pop('part_detail', False)
location_detail = kwargs.pop('location_detail', False)
supplier_detail = kwargs.pop('supplier_detail', False)
super(StockItemSerializer, self).__init__(*args, **kwargs)
@ -93,9 +91,6 @@ class StockItemSerializer(InvenTreeModelSerializer):
if location_detail is not True:
self.fields.pop('location_detail')
if supplier_detail is not True:
self.fields.pop('supplier_part_detail')
class Meta:
model = StockItem
fields = [
@ -111,12 +106,9 @@ class StockItemSerializer(InvenTreeModelSerializer):
'quantity',
'serial',
'supplier_part',
'supplier_part_detail',
'status',
'status_text',
#'tracking_items',
'uid',
#'url',
]
""" These fields are read-only in this context.