Skip to content

Commit a2f9636

Browse files
Handle failed partial_rebuild
1 parent fa1b056 commit a2f9636

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/backend/InvenTree/InvenTree/models.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,16 @@ def delete(self, delete_children=False, delete_items=False):
587587

588588
# 3. Update the tree structure
589589
if tree_id:
590-
self.__class__.objects.partial_rebuild(tree_id)
590+
try:
591+
self.__class__.objects.partial_rebuild(tree_id)
592+
except Exception:
593+
logger.warning(
594+
'Failed to rebuild tree for %s <%s>',
595+
self.__class__.__name__,
596+
self.pk,
597+
)
598+
# If the partial rebuild fails, rebuild the entire tree
599+
self.__class__.objects.rebuild()
591600
else:
592601
self.__class__.objects.rebuild()
593602

0 commit comments

Comments
 (0)