Handle failed partial_rebuild (#9723)

This commit is contained in:
Oliver 2025-06-02 22:21:21 +10:00 committed by GitHub
parent 782ca55887
commit 5c5549c233
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -587,7 +587,16 @@ class InvenTreeTree(MetadataMixin, PluginValidationMixin, MPTTModel):
# 3. Update the tree structure
if tree_id:
self.__class__.objects.partial_rebuild(tree_id)
try:
self.__class__.objects.partial_rebuild(tree_id)
except Exception:
logger.warning(
'Failed to rebuild tree for %s <%s>',
self.__class__.__name__,
self.pk,
)
# If the partial rebuild fails, rebuild the entire tree
self.__class__.objects.rebuild()
else:
self.__class__.objects.rebuild()