From 8e82488f70cfcf8005e5b32045ea4e12be3fc122 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 11 Jun 2019 21:58:20 +1000 Subject: [PATCH] Display 'net stock' value on front page --- InvenTree/part/models.py | 13 +++++++++++++ InvenTree/static/css/inventree.css | 4 ++++ InvenTree/templates/required_part_table.html | 6 +++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 67a82a9504..4fd7360810 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -410,6 +410,19 @@ class Part(models.Model): return max(total, 0) + @property + def net_stock(self): + """ Return the 'net' stock. It takes into account: + + - Stock on hand (total_stock) + - Stock on order (on_order) + - Stock allocated (allocation_count) + + This number (unlike 'available_stock') can be negative. + """ + + return self.total_stock - self.allocation_count + self.on_order + def isStarredBy(self, user): """ Return True if this part has been starred by a particular user """ diff --git a/InvenTree/static/css/inventree.css b/InvenTree/static/css/inventree.css index 3bef992d34..2a98814dda 100644 --- a/InvenTree/static/css/inventree.css +++ b/InvenTree/static/css/inventree.css @@ -14,6 +14,10 @@ color: #ffbb00; } +.red-cell { + background-color: #ec7f7f; +} + .part-price { color: rgb(13, 245, 25); } diff --git a/InvenTree/templates/required_part_table.html b/InvenTree/templates/required_part_table.html index 6f21f5f7df..74feb07336 100644 --- a/InvenTree/templates/required_part_table.html +++ b/InvenTree/templates/required_part_table.html @@ -2,9 +2,9 @@ Part Description - Required In Stock On Order + Allocted Net Stock {% for part in parts %} @@ -14,10 +14,10 @@ {{ part.full_name }} {{ part.description }} - {{ part.allocation_count }} {{ part.total_stock }} {{ part.on_order }} - {{ part.available_stock }} + {{ part.allocation_count }} + {{ part.net_stock }} {% endfor %} \ No newline at end of file