Handle missing part (#12566) (#12567)

Part instance may have already been deleted in post_delete hook for related models.

(cherry picked from commit badf7ab300)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot]
2026-08-08 14:18:00 +10:00
committed by GitHub
co-authored by Oliver
parent a86a648ccc
commit 522ed66720
+7 -2
View File
@@ -4468,8 +4468,13 @@ def update_pricing_after_delete(sender, instance, **kwargs):
InvenTree.ready.canAppAccessDatabase(allow_test=settings.TESTING_PRICING)
and not InvenTree.ready.isImportingData()
):
if instance.part:
instance.part.schedule_pricing_update(create=False)
try:
part = instance.part
part.schedule_pricing_update(create=False)
except Part.DoesNotExist:
# The part instance may have already been deleted,
# in which case we cannot update pricing
pass
class BomItemSubstitute(InvenTree.models.InvenTreeMetadataModel):