Improve reporting in stock history API

This commit is contained in:
Oliver Walters 2021-05-11 17:41:17 +10:00
parent af53b341f0
commit 70ad0ba0de
5 changed files with 18 additions and 7 deletions

View File

@ -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,

View File

@ -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):

View File

@ -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

View File

@ -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,
)

View File

@ -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',