Handle missing record in after_delete_supplier_part (#12772) (#12777)

(cherry picked from commit 8c1c16e59a)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot]
2026-09-03 16:15:02 +10:00
committed by GitHub
co-authored by Oliver
parent 1c4cfd8a47
commit 4a795ccddc
+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(