mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Prevent stock item being added as an installed item inside itself
This commit is contained in:
parent
ef23ab1abc
commit
a9f255be85
@ -715,17 +715,22 @@ class StockItem(MPTTModel):
|
||||
|
||||
for item in items:
|
||||
|
||||
# Prevent recursion
|
||||
if item not in installed:
|
||||
installed.add(item)
|
||||
# Prevent duplication or recursion
|
||||
if item == self or item in installed:
|
||||
continue
|
||||
|
||||
installed.add(item)
|
||||
|
||||
if cascade:
|
||||
sub_items = item.get_installed_items(cascade=True)
|
||||
|
||||
for sub_item in sub_items:
|
||||
|
||||
# Prevent recursion
|
||||
if sub_item not in installed:
|
||||
installed.add(sub_item)
|
||||
if sub_item == self or sub_item in installed:
|
||||
continue
|
||||
|
||||
installed.add(sub_item)
|
||||
|
||||
return installed
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user