Skip to content

[FIX] stock_product_pack: don't skip non detailed packs on dont_create_move#262

Open
gal-adhoc wants to merge 1 commit into
OCA:19.0from
adhoc-dev:19.0-h-122055-gal
Open

[FIX] stock_product_pack: don't skip non detailed packs on dont_create_move#262
gal-adhoc wants to merge 1 commit into
OCA:19.0from
adhoc-dev:19.0-h-122055-gal

Conversation

@gal-adhoc

@gal-adhoc gal-adhoc commented Jul 3, 2026

Copy link
Copy Markdown

Summary

stock.rule.run() only removed the parent pack's procurement (so it doesn't create its own stock.move) when pack_type == "detailed". A non detailed pack with dont_create_move active kept generating a stock.move for 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 on pack_ok + dont_create_move, applying to both detailed and non_detailed packs. Also avoids mutating the procurements list while iterating over it (the previous for ... 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 own stock.move is skipped there's nothing else left to deliver it and qty_delivered would stay stuck at 0 forever. _compute_qty_delivered is extended to consider such a line delivered upon confirmation, matching dont_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 on move_ids.*) never fire for a line that never gets a move.

Test plan

  • Added test_dont_create_move_non_detailed_pack in sale_stock_product_pack: confirms a sale order with a non detailed pack (dont_create_move=True), asserts the delivery has no stock.move for the pack product, and that qty_delivered equals the ordered quantity.
  • Verified the new test fails against the previous code (parent move is created) and passes with the fix.
  • Full product_pack / sale_product_pack / stock_product_pack / sale_stock_product_pack test suites pass against oca/product-pack:19.0 (27 tests, 0 failures).

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @victoralmau, @pedrobaeza,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added mod:product_pack Module product_pack series:19.0 mod:website_sale_product_pack Module website_sale_product_pack mod:sale_stock_product_pack Module sale_stock_product_pack mod:sale_product_pack Module sale_product_pack mod:stock_product_pack Module stock_product_pack labels Jul 3, 2026
@gal-adhoc gal-adhoc force-pushed the 19.0-h-122055-gal branch from d2a357e to 24ff7f5 Compare July 3, 2026 14:27
@OCA-git-bot OCA-git-bot removed mod:product_pack Module product_pack mod:website_sale_product_pack Module website_sale_product_pack mod:sale_product_pack Module sale_product_pack labels Jul 3, 2026
…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.
@gal-adhoc gal-adhoc force-pushed the 19.0-h-122055-gal branch from 24ff7f5 to b907b4e Compare July 3, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:sale_stock_product_pack Module sale_stock_product_pack mod:stock_product_pack Module stock_product_pack series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants