2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 04:00:57 +00:00

Do not let a StockItem be deleted if child items exist

This commit is contained in:
Oliver Walters
2020-02-18 10:41:06 +11:00
parent 49d5573f8b
commit 49118d8083
2 changed files with 10 additions and 0 deletions

View File

@ -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