2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-09 21:30:54 +00:00

Add unit test for deleting part which has pricing information (#3986)

* Add unit test for deleting part which has pricing information

* Test delete of part without pricing

* Deal with post_delete errors

1. Deleting a Part deleted related objects (e.g. InternalPriceBreak)
2. post_delete signal is called for InternalPriceBreak
3. Subsequent updates to Part / PartPricing throw error

* Add unit test for deleting a Part via the API

- Add InternalPriceBreak so the previous error condition is checked

* Fix for unit test

* More unit test fixes

(cherry picked from commit fa346257f5)

* Ensure unique part names for unit testing

* Further unit test fixes
This commit is contained in:
Oliver
2022-12-13 11:07:35 +11:00
committed by GitHub
parent 2f7be70287
commit d246169c93
6 changed files with 138 additions and 35 deletions

View File

@@ -704,7 +704,7 @@ def after_save_supplier_price(sender, instance, created, **kwargs):
if InvenTree.ready.canAppAccessDatabase() and not InvenTree.ready.isImportingData():
if instance.part and instance.part.part:
instance.part.part.pricing.schedule_for_update()
instance.part.part.schedule_pricing_update()
@receiver(post_delete, sender=SupplierPriceBreak, dispatch_uid='post_delete_supplier_price_break')
@@ -714,4 +714,4 @@ def after_delete_supplier_price(sender, instance, **kwargs):
if InvenTree.ready.canAppAccessDatabase() and not InvenTree.ready.isImportingData():
if instance.part and instance.part.part:
instance.part.part.pricing.schedule_for_update()
instance.part.part.schedule_pricing_update()