2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 03:30: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:
Oliver
2023-02-26 16:36:11 +11:00
committed by GitHub
parent 0c5dc2865c
commit b657fb4405
7 changed files with 72 additions and 15 deletions

View File

@ -389,7 +389,7 @@ class PurchaseOrder(Order):
# Schedule pricing update for any referenced parts
for line in self.lines.all():
if line.part and line.part.part:
line.part.part.schedule_pricing_update()
line.part.part.schedule_pricing_update(create=True)
trigger_event('purchaseorder.completed', id=self.pk)
@ -782,7 +782,7 @@ class SalesOrder(Order):
# Schedule pricing update for any referenced parts
for line in self.lines.all():
line.part.schedule_pricing_update()
line.part.schedule_pricing_update(create=True)
trigger_event('salesorder.completed', id=self.pk)