diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 1a4a48ad62..43d3eef145 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -376,10 +376,14 @@ class StockItem(MPTTModel): def can_delete(self): """ Can this stock item be deleted? It can NOT be deleted under the following circumstances: + - Has child StockItems - Has a serial number and is tracked - Is installed inside another StockItem """ + if self.child_count > 0: + return False + if self.part.trackable and self.serial is not None: return False diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 4e32356101..3e398ba16a 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -43,15 +43,21 @@ + {% if item.can_delete %} + {% endif %}
{% if item.serialized %}