From 08fbdf660bf4ca92c60229ef5f3d590b1fe925e6 Mon Sep 17 00:00:00 2001 From: eeintech Date: Mon, 14 Jun 2021 14:19:10 -0400 Subject: [PATCH] Fix for #1661 --- InvenTree/stock/serializers.py | 8 ++++++++ InvenTree/templates/js/stock.js | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 9bcdc5182e..d60689ccef 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -161,6 +161,13 @@ class StockItemSerializer(InvenTreeModelSerializer): required_tests = serializers.IntegerField(source='required_test_count', read_only=True, required=False) + purchase_price = serializers.SerializerMethodField() + + def get_purchase_price(self, obj): + """ Return purchase_price (Money field) as string (includes currency) """ + + return str(obj.purchase_price) if obj.purchase_price else '-' + def __init__(self, *args, **kwargs): part_detail = kwargs.pop('part_detail', False) @@ -215,6 +222,7 @@ class StockItemSerializer(InvenTreeModelSerializer): 'tracking_items', 'uid', 'updated', + 'purchase_price', ] """ These fields are read-only in this context. diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js index 0ce10b28a7..4e992df67f 100644 --- a/InvenTree/templates/js/stock.js +++ b/InvenTree/templates/js/stock.js @@ -660,6 +660,11 @@ function loadStockTable(table, options) { title: '{% trans "Last Updated" %}', sortable: true, }, + { + field: 'purchase_price', + title: '{% trans "Purchase Price" %}', + sortable: true, + }, { field: 'packaging', title: '{% trans "Packaging" %}',