mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 11:10:54 +00:00
Pricing bug fix (#4422)
* Control when a new PartPricing object can be created - Prevent this when calling from an on_delete signal - There is an edge case where deleting a part triggers a series of on_delete signals inside an atomic transaction - When the new PartPricing object is created, * Add unit testing: - Ensure PartPricing gets created when a new StockItem is added - Part.delete() works without error - PartPricing instances are deleted also * style fixes
This commit is contained in:
@ -2004,8 +2004,8 @@ def after_delete_stock_item(sender, instance: StockItem, **kwargs):
|
||||
InvenTree.tasks.offload_task(part_tasks.notify_low_stock_if_required, instance.part)
|
||||
|
||||
# Schedule an update on parent part pricing
|
||||
if InvenTree.ready.canAppAccessDatabase():
|
||||
instance.part.schedule_pricing_update()
|
||||
if InvenTree.ready.canAppAccessDatabase(allow_test=True):
|
||||
instance.part.schedule_pricing_update(create=False)
|
||||
|
||||
|
||||
@receiver(post_save, sender=StockItem, dispatch_uid='stock_item_post_save_log')
|
||||
@ -2017,8 +2017,8 @@ def after_save_stock_item(sender, instance: StockItem, created, **kwargs):
|
||||
# Run this check in the background
|
||||
InvenTree.tasks.offload_task(part_tasks.notify_low_stock_if_required, instance.part)
|
||||
|
||||
if InvenTree.ready.canAppAccessDatabase():
|
||||
instance.part.schedule_pricing_update()
|
||||
if InvenTree.ready.canAppAccessDatabase(allow_test=True):
|
||||
instance.part.schedule_pricing_update(create=True)
|
||||
|
||||
|
||||
class StockItemAttachment(InvenTreeAttachment):
|
||||
|
Reference in New Issue
Block a user