Skip to content

[15.0][FIX] purchase_request: do not close allocations on locked orders - #3167

Open
les-adhoc wants to merge 1 commit into
OCA:15.0from
adhoc-dev:15.0-h-126544-les
Open

[15.0][FIX] purchase_request: do not close allocations on locked orders#3167
les-adhoc wants to merge 1 commit into
OCA:15.0from
adhoc-dev:15.0-h-126544-les

Conversation

@les-adhoc

@les-adhoc les-adhoc commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fix forwarded from 18.0 to 15.0

Original pull request (18.0): #3160

done on a purchase order means "Locked", a modification lock, not a
completion, so a locked order must not close the allocation. See the original
PR for the full analysis and the regression history (#1419, #1422).

The test is adapted to 15.0: qty_done on the move line, and mail.mt_comment
as the subtype, since the dedicated mt_request_picking_done subtype only
exists from 16.0 on.

_compute_open_product_qty treats a purchase order line in state done as a
finished purchase and zeroes the open quantity. In Odoo that state means
"Locked", a modification lock, not a completion: receipts still happen
afterwards, and core creates and processes them for locked orders
(_create_picking accepts both purchase and done).

With po_lock = 'lock' the order reaches done at approval time, so the
allocation is closed before any receipt can happen. As a consequence
stock.move.line.allocate() never allocates the incoming quantity, the
requester is never notified of the receipt, qty_done and qty_in_progress
stay at 0 on the request line, and stock.move.copy_data carries no
allocation over to backorders. Nothing fails and nothing is logged.

This is a regression: the same one line change was requested by a
maintainer in OCA#1419 and merged into 14.0 by OCA#1422, but the forward port
to 15.0 brought back the version including done, and 15.0 up to 18.0
still carry it.

cancel is the only state that really means nothing else will be
allocated: once a receipt completes, allocated_product_qty reaches
requested_product_uom_qty and the open quantity becomes 0 on its own.

Add a test covering the locked order flow, which no test exercised
because po_lock defaults to edit.

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HviorForgeFlow

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@HviorForgeFlow The merge process could not start, because command git fetch --quiet --force --prune https://github.com/OCA/purchase-workflow 'refs/heads/*:refs/heads/*' failed with output:

fatal: could not read Username for 'https://github.com': No such device or address
fatal: expected flush after ref listing

@HviorForgeFlow

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 15.0-ocabot-merge-pr-3167-by-HviorForgeFlow-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@HviorForgeFlow your merge command was aborted due to failed check(s), which you can inspect on this commit of 15.0-ocabot-merge-pr-3167-by-HviorForgeFlow-bump-patch.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@HviorForgeFlow

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 15.0-ocabot-merge-pr-3167-by-HviorForgeFlow-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@HviorForgeFlow your merge command was aborted due to failed check(s), which you can inspect on this commit of 15.0-ocabot-merge-pr-3167-by-HviorForgeFlow-bump-patch.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@HviorForgeFlow

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 15.0-ocabot-merge-pr-3167-by-HviorForgeFlow-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@HviorForgeFlow your merge command was aborted due to failed check(s), which you can inspect on this commit of 15.0-ocabot-merge-pr-3167-by-HviorForgeFlow-bump-patch.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants