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:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user