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 }} <div class='btn-group'> <button id='stock-actions' title='{% trans "Stock adjustment actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button> <ul class='dropdown-menu' role='menu'> - {% if item.in_stock %} + {% if item.can_adjust_location %} {% if not item.serialized %} <li><a href='#' id='stock-count' title='{% trans "Count stock" %}'><span class='fas fa-clipboard-list'></span> {% trans "Count stock" %}</a></li> <li><a href='#' id='stock-add' title='{% trans "Add stock" %}'><span class='fas fa-plus-circle icon-green'></span> {% trans "Add stock" %}</a></li>