Handle missing record in after_delete_supplier_part (#12772)

This commit is contained in:
Oliver
2026-09-03 13:57:19 +10:00
committed by GitHub
parent fa52affe98
commit 8c1c16e59a
+13 -4
View File
@@ -1061,12 +1061,21 @@ def after_delete_supplier_part(sender, instance, **kwargs):
Triggers a pricing update for the linked Part, so that removal of a
supplier part is reflected in Part pricing and BOM cost rollups.
"""
from part.models import Part
if (
InvenTree.ready.canAppAccessDatabase(allow_test=settings.TESTING_PRICING)
and not InvenTree.ready.isImportingData()
and instance.part
not InvenTree.ready.canAppAccessDatabase(allow_test=settings.TESTING_PRICING)
or InvenTree.ready.isImportingData()
or InvenTree.ready.isRunningMigrations()
):
instance.part.schedule_pricing_update(create=False)
return
try:
if part := instance.part:
part.schedule_pricing_update(create=False)
except (Part.DoesNotExist, SupplierPart.DoesNotExist):
# The underlying SupplierPart instance has been deleted
return
@receiver(