From fe0d356675785c9e6016ac9d330b4781e7bf435c Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Sun, 3 Jan 2021 13:13:14 +1100 Subject: [PATCH] pops the purchase_price field instead of using a HiddenInput Using a HiddenInput on a MoneyFormField causes a validation error, for some reason... --- InvenTree/stock/views.py | 4 ++-- InvenTree/templates/js/stock.js | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 3a29b66ee3..fdd58f1e96 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -1522,8 +1522,8 @@ class StockItemCreate(AjaxCreateView): form.rebuild_layout() if not part.purchaseable: - form.fields['purchase_price'].widget = HiddenInput() - + form.fields.pop('purchase_price') + # Hide the 'part' field (as a valid part is selected) # form.fields['part'].widget = HiddenInput() diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js index da57d4f048..f8a7c38d2c 100644 --- a/InvenTree/templates/js/stock.js +++ b/InvenTree/templates/js/stock.js @@ -278,7 +278,7 @@ function loadStockTable(table, options) { if (row.is_building && row.build) { // StockItem is currently being built! - text = "{% trans "In production" %}"; + text = '{% trans "In production" %}'; url = `/build/${row.build}/`; } else if (row.belongs_to) { // StockItem is installed inside a different StockItem @@ -286,17 +286,17 @@ function loadStockTable(table, options) { url = `/stock/item/${row.belongs_to}/installed/`; } else if (row.customer) { // StockItem has been assigned to a customer - text = "{% trans "Shipped to customer" %}"; + text = '{% trans "Shipped to customer" %}'; url = `/company/${row.customer}/assigned-stock/`; } else if (row.sales_order) { // StockItem has been assigned to a sales order - text = "{% trans "Assigned to Sales Order" %}"; + text = '{% trans "Assigned to Sales Order" %}'; url = `/order/sales-order/${row.sales_order}/`; } else if (row.location) { text = row.location_detail.pathstring; url = `/stock/location/${row.location}/`; } else { - text = "<i>{% trans "No stock location set" %}</i>"; + text = '<i>{% trans "No stock location set" %}</i>'; url = ''; } @@ -336,7 +336,13 @@ function loadStockTable(table, options) { return html; } else if (field == 'part_detail.IPN') { - return row.part_detail.IPN; + var ipn = row.part_detail.IPN; + + if (ipn) { + return ipn; + } else { + return '-'; + } } else if (field == 'part_detail.description') { return row.part_detail.description;