From ea4b713eedf51b2d64b1d37e3951324264db022e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 19 Feb 2021 15:13:56 +1100 Subject: [PATCH] Allow adjustment for destroyed (or lost) stock --- InvenTree/stock/models.py | 21 +++++++++++++++++++ .../stock/templates/stock/item_base.html | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 5088a314b5..ef934f73d0 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -832,6 +832,27 @@ class StockItem(MPTTModel): return query.exists() + @property + def can_adjust_location(self): + """ + Returns True if the stock location can be "adjusted" for this part + + Cannot be adjusted if: + - Has been delivered to a customer + - Has been installed inside another StockItem + """ + + if self.customer is not None: + return False + + if self.belongs_to is not None: + return False + + if self.sales_order is not None: + return False + + return True + @property def tracking_info_count(self): return self.tracking_info.count() diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index aa33412ab3..a9c8337b57 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -155,7 +155,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}