fix: trigger pricing recalculation when SupplierPart pack_quantity changes - #12421
fix: trigger pricing recalculation when SupplierPart pack_quantity changes#12421amanjain57-gif wants to merge 6 commits into
Conversation
When a SupplierPart's pack_quantity is updated after price breaks have already been created, the Part's pricing (and BOM cost rollups for any assemblies using that part) was not recalculated. This is because there was no post_save or post_delete signal handler for the SupplierPart model to trigger schedule_pricing_update on the linked Part. Added post_save and post_delete signal handlers for SupplierPart that mirror the existing SupplierPriceBreak signal handlers. The pricing cascade (via update_assemblies) ensures BOM line costs in parent assemblies are also updated. Fixes inventree#12285
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
|
please address code style issues |
|
Fixed — ran |
|
@amanjain57-gif make sure you are using the same pre-commit config that we are. The ruff format checks may be different version |
|
Applied ruff format with |
|
@SchrodingersGat Confirmed — matched your |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #12421 +/- ##
==========================================
- Coverage 86.76% 85.93% -0.83%
==========================================
Files 1444 1444
Lines 96231 97552 +1321
Branches 11216 11216
==========================================
+ Hits 83491 83832 +341
- Misses 12676 13656 +980
Partials 64 64
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary
Fixes #12285
When a SupplierPart's
pack_quantityis updated after price breaks exist, the Part's pricing and BOM cost rollups arenot recalculated. The root cause is that no
post_savesignal existed for theSupplierPartmodel to triggerschedule_pricing_updateon the linked Part.Changes
post_savesignal handler forSupplierPartthat triggers pricing recalculation on the linked Part (mirrorsexisting
SupplierPriceBreakhandler)post_deletesignal handler forSupplierPartfor completenesspack_quantitycorrectly recalculates the per-unit supplier priceHow it works
The existing
update_supplier_cost()method already correctly divides price bypack_quantity_native. The missingpiece was that changing
pack_quantityon aSupplierPartdidn't trigger the recalculation. The pricing cascade viaupdate_assemblies()ensures BOM line costs in parent assemblies also update.