diff --git a/InvenTree/company/templates/company/supplier_part.html b/InvenTree/company/templates/company/supplier_part.html
index ebe4f658ad..205f2da352 100644
--- a/InvenTree/company/templates/company/supplier_part.html
+++ b/InvenTree/company/templates/company/supplier_part.html
@@ -149,7 +149,7 @@ src="{% static 'img/blank_image.png' %}"
|
{% trans "Pack Quantity" %} |
- {% decimal part.pack_size %}{% if part.part.units %} {{ part.part.units }}{% endif %} |
+ {% decimal part.pack_size %} {% include "part/part_units.html" with part=part.part %} |
{% endif %}
{% if part.note %}
diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html
index 69e6ccfdf8..f649f74c0b 100644
--- a/InvenTree/part/templates/part/part_base.html
+++ b/InvenTree/part/templates/part/part_base.html
@@ -187,7 +187,7 @@
|
{% trans "Available Stock" %} |
- {% decimal available %}{% if part.units %} {{ part.units }}{% endif %} |
+ {% decimal available %} {% include "part/part_units.html" %} |
|
@@ -198,14 +198,14 @@
|
{% trans "Minimum Stock" %} |
- {{ part.minimum_stock }} {{ part.units }} |
+ {{ part.minimum_stock }} {% include "part/part_units.html" %} |
{% endif %}
{% if on_order > 0 %}
|
{% trans "On Order" %} |
- {% decimal on_order %} {{ part.units }} |
+ {% decimal on_order %} {% include "part/part_units.html" %}/td>
|
{% endif %}
{% if part.component %}
diff --git a/InvenTree/part/templates/part/part_units.html b/InvenTree/part/templates/part/part_units.html
new file mode 100644
index 0000000000..86189debf8
--- /dev/null
+++ b/InvenTree/part/templates/part/part_units.html
@@ -0,0 +1 @@
+{% if part.units %}{{ part.units }}{% endif %}
diff --git a/InvenTree/part/templates/part/stock_count.html b/InvenTree/part/templates/part/stock_count.html
index 517d502f9d..41dda6ce5d 100644
--- a/InvenTree/part/templates/part/stock_count.html
+++ b/InvenTree/part/templates/part/stock_count.html
@@ -1,7 +1,7 @@
{% load inventree_extras %}
{% load i18n %}
-{% decimal total_stock %} {{ part.units }}
+{% decimal total_stock %} {% include "part/part_units.html" %}
{% if total_stock == 0 %}
{% trans "No Stock" %}
diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html
index af98766867..197b504e96 100644
--- a/InvenTree/stock/templates/stock/item_base.html
+++ b/InvenTree/stock/templates/stock/item_base.html
@@ -348,7 +348,7 @@
{% trans "Available Quantity" %}
- {% if item.quantity != available %}{% decimal available %} / {% endif %}{% decimal item.quantity %} {% if item.part.units %}{{ item.part.units }}{% endif %}
+ {% if item.quantity != available %}{% decimal available %} / {% endif %}{% decimal item.quantity %} {% include "part/part_units.html" with part=item.part %}
|
{% endif %}
diff --git a/InvenTree/stock/test_views.py b/InvenTree/stock/test_views.py
index acf1626136..d7444e181f 100644
--- a/InvenTree/stock/test_views.py
+++ b/InvenTree/stock/test_views.py
@@ -49,7 +49,7 @@ class StockDetailTest(StockViewTestCase):
# Quantity
self.assertIn('Available Quantity
', html)
- self.assertIn('4000
', html)
+ self.assertIn('4000', html)
# Batch code
self.assertIn('Batch', html)
diff --git a/InvenTree/templates/email/build_order_required_stock.html b/InvenTree/templates/email/build_order_required_stock.html
index 5f4015da27..aba84be41a 100644
--- a/InvenTree/templates/email/build_order_required_stock.html
+++ b/InvenTree/templates/email/build_order_required_stock.html
@@ -25,9 +25,9 @@
{{ line.part.full_name }}{% if part.description %} - {{ part.description }}{% endif %}
- {% decimal line.required %} {% if line.part.units %}{{ line.part.units }}{% endif %}
+ {% decimal line.required %} {% include "part/part_units.html" with part=line.part %}
|
- {% decimal line.available %} {% if line.part.units %}{{ line.part.units }}{% endif %} |
+ {% decimal line.available %} {% include "part/part_units.html" with part=line.part %} |
{% endfor %}
diff --git a/InvenTree/templates/js/translated/company.js b/InvenTree/templates/js/translated/company.js
index 4025e8b82c..d9eeddf60e 100644
--- a/InvenTree/templates/js/translated/company.js
+++ b/InvenTree/templates/js/translated/company.js
@@ -998,7 +998,7 @@ function loadSupplierPartTable(table, url, options) {
formatter: function(value, row) {
var output = `${value}`;
- if (row.part_detail) {
+ if (row.part_detail && row.part_detail.units) {
output += ` ${row.part_detail.units}`;
}
diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js
index 46e9c7dba1..5b504d8dda 100644
--- a/InvenTree/templates/js/translated/part.js
+++ b/InvenTree/templates/js/translated/part.js
@@ -574,43 +574,41 @@ function duplicateBom(part_id, options={}) {
function partStockLabel(part, options={}) {
// Prevent literal string 'null' from being displayed
- if (part.units == null) {
- part.units = '';
- }
+ var units = part.units || '';
if (part.in_stock) {
// There IS stock available for this part
// Is stock "low" (below the 'minimum_stock' quantity)?
if ((part.minimum_stock > 0) && (part.minimum_stock > part.in_stock)) {
- return `{% trans "Low stock" %}: ${part.in_stock}${part.units}`;
+ return `{% trans "Low stock" %}: ${part.in_stock} ${units}`;
} else if (part.unallocated_stock == 0) {
if (part.ordering) {
// There is no available stock, but stock is on order
- return `{% trans "On Order" %}: ${part.ordering}${part.units}`;
+ return `{% trans "On Order" %}: ${part.ordering} ${units}`;
} else if (part.building) {
// There is no available stock, but stock is being built
- return `{% trans "Building" %}: ${part.building}${part.units}`;
+ return `{% trans "Building" %}: ${part.building} ${units}`;
} else {
// There is no available stock at all
return `{% trans "No stock available" %}`;
}
} else if (part.unallocated_stock < part.in_stock) {
// Unallocated quanttiy is less than total quantity
- return `{% trans "Available" %}: ${part.unallocated_stock}/${part.in_stock}${part.units}`;
+ return `{% trans "Available" %}: ${part.unallocated_stock}/${part.in_stock} ${units}`;
} else {
// Stock is completely available
- return `{% trans "Available" %}: ${part.unallocated_stock}${part.units}`;
+ return `{% trans "Available" %}: ${part.unallocated_stock} ${units}`;
}
} else {
// There IS NO stock available for this part
if (part.ordering) {
// There is no stock, but stock is on order
- return `{% trans "On Order" %}: ${part.ordering}${part.units}`;
+ return `{% trans "On Order" %}: ${part.ordering} ${units}`;
} else if (part.building) {
// There is no stock, but stock is being built
- return `{% trans "Building" %}: ${part.building}${part.units}`;
+ return `{% trans "Building" %}: ${part.building} ${units}`;
} else {
// There is no stock
return `{% trans "No Stock" %}`;
@@ -1324,8 +1322,8 @@ function partGridTile(part) {
// Rows for table view
var rows = '';
- var units = part.units;
- var stock = `${part.in_stock} ${part.units}`;
+ var units = part.units || '';
+ var stock = `${part.in_stock} ${units}`;
if (!part.in_stock) {
stock = `{% trans "No Stock" %}`;
diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js
index 67dd18fb41..b2933f5024 100644
--- a/InvenTree/templates/js/translated/stock.js
+++ b/InvenTree/templates/js/translated/stock.js
@@ -1764,7 +1764,7 @@ function loadStockTable(table, options) {
// Format floating point numbers with this one weird trick
val = formatDecimal(value);
- if (row.part_detail) {
+ if (row.part_detail && row.part_detail.units) {
val += ` ${row.part_detail.units}`;
}
}