Allow adjustment for destroyed (or lost) stock

This commit is contained in:
Oliver Walters 2021-02-19 15:13:56 +11:00
parent ca16e4f35d
commit ea4b713eed
2 changed files with 22 additions and 1 deletions

View File

@ -832,6 +832,27 @@ class StockItem(MPTTModel):
return query.exists() 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 @property
def tracking_info_count(self): def tracking_info_count(self):
return self.tracking_info.count() return self.tracking_info.count()

View File

@ -155,7 +155,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
<div class='btn-group'> <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> <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'> <ul class='dropdown-menu' role='menu'>
{% if item.in_stock %} {% if item.can_adjust_location %}
{% if not item.serialized %} {% 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-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> <li><a href='#' id='stock-add' title='{% trans "Add stock" %}'><span class='fas fa-plus-circle icon-green'></span> {% trans "Add stock" %}</a></li>