mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Check before calling schedule_pricing_update (#7871)
Ref: https://github.com/inventree/InvenTree/pull/7807#issuecomment-2287770192
This commit is contained in:
parent
2244f5fb27
commit
697ab1653a
@ -1161,7 +1161,8 @@ class SalesOrder(TotalPriceMixin, Order):
|
|||||||
|
|
||||||
# Schedule pricing update for any referenced parts
|
# Schedule pricing update for any referenced parts
|
||||||
for line in self.lines.all():
|
for line in self.lines.all():
|
||||||
line.part.schedule_pricing_update(create=True)
|
if line.part:
|
||||||
|
line.part.schedule_pricing_update(create=True)
|
||||||
|
|
||||||
trigger_event('salesorder.completed', id=self.pk)
|
trigger_event('salesorder.completed', id=self.pk)
|
||||||
|
|
||||||
|
@ -4509,7 +4509,8 @@ def update_pricing_after_edit(sender, instance, created, **kwargs):
|
|||||||
"""Callback function when a part price break is created or updated."""
|
"""Callback function when a part price break is created or updated."""
|
||||||
# Update part pricing *unless* we are importing data
|
# Update part pricing *unless* we are importing data
|
||||||
if InvenTree.ready.canAppAccessDatabase() and not InvenTree.ready.isImportingData():
|
if InvenTree.ready.canAppAccessDatabase() and not InvenTree.ready.isImportingData():
|
||||||
instance.part.schedule_pricing_update(create=True)
|
if instance.part:
|
||||||
|
instance.part.schedule_pricing_update(create=True)
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_delete, sender=BomItem, dispatch_uid='post_delete_bom_item')
|
@receiver(post_delete, sender=BomItem, dispatch_uid='post_delete_bom_item')
|
||||||
@ -4525,7 +4526,8 @@ def update_pricing_after_delete(sender, instance, **kwargs):
|
|||||||
"""Callback function when a part price break is deleted."""
|
"""Callback function when a part price break is deleted."""
|
||||||
# Update part pricing *unless* we are importing data
|
# Update part pricing *unless* we are importing data
|
||||||
if InvenTree.ready.canAppAccessDatabase() and not InvenTree.ready.isImportingData():
|
if InvenTree.ready.canAppAccessDatabase() and not InvenTree.ready.isImportingData():
|
||||||
instance.part.schedule_pricing_update(create=False)
|
if instance.part:
|
||||||
|
instance.part.schedule_pricing_update(create=False)
|
||||||
|
|
||||||
|
|
||||||
class BomItemSubstitute(InvenTree.models.InvenTreeMetadataModel):
|
class BomItemSubstitute(InvenTree.models.InvenTreeMetadataModel):
|
||||||
|
@ -2293,7 +2293,8 @@ def after_delete_stock_item(sender, instance: StockItem, **kwargs):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Schedule an update on parent part pricing
|
# Schedule an update on parent part pricing
|
||||||
instance.part.schedule_pricing_update(create=False)
|
if instance.part:
|
||||||
|
instance.part.schedule_pricing_update(create=False)
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=StockItem, dispatch_uid='stock_item_post_save_log')
|
@receiver(post_save, sender=StockItem, dispatch_uid='stock_item_post_save_log')
|
||||||
@ -2312,7 +2313,8 @@ def after_save_stock_item(sender, instance: StockItem, created, **kwargs):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Schedule an update on parent part pricing
|
# Schedule an update on parent part pricing
|
||||||
instance.part.schedule_pricing_update(create=True)
|
if instance.part:
|
||||||
|
instance.part.schedule_pricing_update(create=True)
|
||||||
|
|
||||||
|
|
||||||
class StockItemTracking(InvenTree.models.InvenTreeModel):
|
class StockItemTracking(InvenTree.models.InvenTreeModel):
|
||||||
|
Loading…
Reference in New Issue
Block a user