diff --git a/src/backend/InvenTree/stock/models.py b/src/backend/InvenTree/stock/models.py index 5b6c6dab18..192b8fa62f 100644 --- a/src/backend/InvenTree/stock/models.py +++ b/src/backend/InvenTree/stock/models.py @@ -2224,15 +2224,16 @@ def after_delete_stock_item(sender, instance: StockItem, **kwargs): """Function to be executed after a StockItem object is deleted.""" from part import tasks as part_tasks - if not InvenTree.ready.isImportingData(): + if not InvenTree.ready.isImportingData() and InvenTree.ready.canAppAccessDatabase( + allow_test=True + ): # Run this check in the background InvenTree.tasks.offload_task( part_tasks.notify_low_stock_if_required, instance.part ) # Schedule an update on parent part pricing - if InvenTree.ready.canAppAccessDatabase(allow_test=True): - instance.part.schedule_pricing_update(create=False) + instance.part.schedule_pricing_update(create=False) @receiver(post_save, sender=StockItem, dispatch_uid='stock_item_post_save_log') @@ -2240,14 +2241,18 @@ def after_save_stock_item(sender, instance: StockItem, created, **kwargs): """Hook function to be executed after StockItem object is saved/updated.""" from part import tasks as part_tasks - if created and not InvenTree.ready.isImportingData(): + if ( + created + and not InvenTree.ready.isImportingData() + and InvenTree.ready.canAppAccessDatabase(allow_test=True) + ): # Run this check in the background InvenTree.tasks.offload_task( part_tasks.notify_low_stock_if_required, instance.part ) - if InvenTree.ready.canAppAccessDatabase(allow_test=True): - instance.part.schedule_pricing_update(create=True) + # Schedule an update on parent part pricing + instance.part.schedule_pricing_update(create=True) class StockItemAttachment(InvenTree.models.InvenTreeAttachment):