mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-09 22:30:17 +00:00
Handle missing record in after_delete_supplier_part (#12772)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user