mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improve reporting in stock history API
This commit is contained in:
parent
af53b341f0
commit
70ad0ba0de
@ -368,9 +368,6 @@ class PurchaseOrder(Order):
|
||||
|
||||
stock.save()
|
||||
|
||||
text = _("Received items")
|
||||
note = _('Received {n} items against order {name}').format(n=quantity, name=str(self))
|
||||
|
||||
tracking_info = {
|
||||
'status': status,
|
||||
'purchaseorder': self.pk,
|
||||
|
@ -130,7 +130,7 @@ class StockAttachmentAdmin(admin.ModelAdmin):
|
||||
|
||||
|
||||
class StockTrackingAdmin(ImportExportModelAdmin):
|
||||
list_display = ('item', 'date', 'title')
|
||||
list_display = ('item', 'date', 'label')
|
||||
|
||||
|
||||
class StockItemTestResultAdmin(admin.ModelAdmin):
|
||||
|
@ -965,7 +965,7 @@ class StockItemTestResultList(generics.ListCreateAPIView):
|
||||
test_result.save()
|
||||
|
||||
|
||||
class StockTrackingList(generics.ListCreateAPIView):
|
||||
class StockTrackingList(generics.ListAPIView):
|
||||
""" API endpoint for list view of StockItemTracking objects.
|
||||
|
||||
StockItemTracking objects are read-only
|
||||
|
@ -1620,6 +1620,13 @@ class StockItemTracking(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return '/stock/track/{pk}'.format(pk=self.id)
|
||||
|
||||
def label(self):
|
||||
|
||||
if self.tracking_type in StockHistoryCode.keys():
|
||||
return StockHistoryCode.label(self.tracking_type)
|
||||
else:
|
||||
return self.title
|
||||
|
||||
tracking_type = models.IntegerField(
|
||||
default=StockHistoryCode.LEGACY,
|
||||
)
|
||||
|
@ -351,10 +351,14 @@ class StockTrackingSerializer(InvenTreeModelSerializer):
|
||||
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
|
||||
label = serializers.CharField(read_only=True)
|
||||
|
||||
item_detail = StockItemSerializerBrief(source='item', many=False, read_only=True)
|
||||
|
||||
user_detail = UserSerializerBrief(source='user', many=False, read_only=True)
|
||||
|
||||
deltas = serializers.JSONField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = StockItemTracking
|
||||
fields = [
|
||||
@ -363,10 +367,13 @@ class StockTrackingSerializer(InvenTreeModelSerializer):
|
||||
'item',
|
||||
'item_detail',
|
||||
'date',
|
||||
'title',
|
||||
'notes',
|
||||
'deltas',
|
||||
'label',
|
||||
'link',
|
||||
'notes',
|
||||
'quantity',
|
||||
'title',
|
||||
'tracking_type',
|
||||
'user',
|
||||
'user_detail',
|
||||
'system',
|
||||
|
Loading…
Reference in New Issue
Block a user