[FIX] stock_product_pack: don't skip non detailed packs on dont_create_move#262
Open
gal-adhoc wants to merge 1 commit into
Open
[FIX] stock_product_pack: don't skip non detailed packs on dont_create_move#262gal-adhoc wants to merge 1 commit into
gal-adhoc wants to merge 1 commit into
Conversation
Contributor
|
Hi @victoralmau, @pedrobaeza, |
d2a357e to
24ff7f5
Compare
…e_move stock.rule.run() only removed the parent pack procurement (so it doesn't create its own stock.move) when pack_type was 'detailed'. Non detailed packs with 'dont_create_move' active kept generating a stock.move for the parent product in the delivery, defeating the purpose of the flag. The exclusion now only depends on pack_ok + dont_create_move, so it applies regardless of the pack display type. Also avoids mutating the procurements list while iterating over it. Non detailed packs don't expand into separate component order lines (only detailed ones do), so once its own stock.move is skipped there's nothing else left to deliver it. sale_stock_product_pack's _compute_qty_delivered is extended to consider such a line delivered upon confirmation, matching dont_create_move's own field help text.
24ff7f5 to
b907b4e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stock.rule.run()only removed the parent pack's procurement (so it doesn't create its ownstock.move) whenpack_type == "detailed". A non detailed pack withdont_create_moveactive kept generating astock.movefor the parent product in the delivery, defeating the purpose of the flag.Change
stock_product_pack/models/stock_rule.py: the exclusion now depends only onpack_ok+dont_create_move, applying to bothdetailedandnon_detailedpacks. Also avoids mutating theprocurementslist while iterating over it (the previousfor ... procurements.remove(...)pattern could skip elements).sale_stock_product_pack/models/sale_order.py: non detailed packs don't expand into separate component order lines (only detailed ones do), so once the pack's ownstock.moveis skipped there's nothing else left to deliver it andqty_deliveredwould stay stuck at 0 forever._compute_qty_deliveredis extended to consider such a line delivered upon confirmation, matchingdont_create_move's own field help text ("will be set as delivered upon sale confirmation"). Added@api.depends("state", "product_id.dont_create_move")since the existing dependencies (all onmove_ids.*) never fire for a line that never gets a move.Test plan
test_dont_create_move_non_detailed_packinsale_stock_product_pack: confirms a sale order with a non detailed pack (dont_create_move=True), asserts the delivery has nostock.movefor the pack product, and thatqty_deliveredequals the ordered quantity.product_pack/sale_product_pack/stock_product_pack/sale_stock_product_packtest suites pass againstoca/product-pack:19.0(27 tests, 0 failures).