From e6598b51156b3376a7851179fb6c78bfb9d27069 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 21 Jun 2021 16:58:39 +1000 Subject: [PATCH 1/2] Displays "purchase order" column in StockItem table --- .../order/templates/order/order_base.html | 2 +- .../templates/order/sales_order_base.html | 2 +- InvenTree/stock/serializers.py | 8 +++++++ InvenTree/templates/js/stock.js | 21 +++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 642f866506..c7ba6be8a4 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -75,7 +75,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Order Reference" %} - {{ order.reference }}{% include "clip.html"%} + {% settings_value 'PURCHASEORDER_REFERENCE_PREFIX' %}{{ order.reference }}{% include "clip.html"%} diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index d3f4ba74a2..b342cefe66 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -77,7 +77,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Order Reference" %} - {{ order.reference }}{% include "clip.html"%} + {% settings_value 'SALESORDER_REFERENCE_PREFIX' %}{{ order.reference }}{% include "clip.html"%} diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index d60689ccef..a0b7e3403a 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -81,6 +81,7 @@ class StockItemSerializer(InvenTreeModelSerializer): 'belongs_to', 'build', 'customer', + 'purchase_order', 'sales_order', 'supplier_part', 'supplier_part__supplier', @@ -163,6 +164,10 @@ class StockItemSerializer(InvenTreeModelSerializer): purchase_price = serializers.SerializerMethodField() + purchase_order_reference = serializers.CharField(source='purchase_order.reference', read_only=True) + + sales_order_reference = serializers.CharField(source='sales_order.reference', read_only=True) + def get_purchase_price(self, obj): """ Return purchase_price (Money field) as string (includes currency) """ @@ -208,10 +213,13 @@ class StockItemSerializer(InvenTreeModelSerializer): 'packaging', 'part', 'part_detail', + 'purchase_order', + 'purchase_order_reference', 'pk', 'quantity', 'required_tests', 'sales_order', + 'sales_order_reference', 'serial', 'stale', 'status', diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js index 4e992df67f..4dd2093896 100644 --- a/InvenTree/templates/js/stock.js +++ b/InvenTree/templates/js/stock.js @@ -660,6 +660,27 @@ function loadStockTable(table, options) { title: '{% trans "Last Updated" %}', sortable: true, }, + { + field: 'purchase_order', + title: '{% trans "Purchase Order" %}', + formatter: function(value, row) { + if (!value) { + return '-'; + } + + var link = `/order/purchase-order/${row.purchase_order}/`; + var text = `${row.purchase_order}`; + + if (row.purchase_order_reference) { + + var prefix = '{% settings_value "PURCHASEORDER_REFERENCE_PREFIX" %}'; + + text = prefix + row.purchase_order_reference; + } + + return renderLink(text, link); + } + }, { field: 'purchase_price', title: '{% trans "Purchase Price" %}', From 6d294183645a653c934bb54b188e7012d66eec41 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 21 Jun 2021 17:03:00 +1000 Subject: [PATCH 2/2] Prevent "rebuild" command from running certain things --- InvenTree/InvenTree/ready.py | 1 + 1 file changed, 1 insertion(+) diff --git a/InvenTree/InvenTree/ready.py b/InvenTree/InvenTree/ready.py index 9e64a2e6c7..4acbcae9af 100644 --- a/InvenTree/InvenTree/ready.py +++ b/InvenTree/InvenTree/ready.py @@ -33,6 +33,7 @@ def canAppAccessDatabase(): 'createsuperuser', 'wait_for_db', 'prerender', + 'rebuild', 'collectstatic', 'makemessages', 'compilemessages',