[FIX] purchase_stock_ux: fix received qty on exchange returns#341
Open
jcadhoc wants to merge 1 commit into
Open
[FIX] purchase_stock_ux: fix received qty on exchange returns#341jcadhoc wants to merge 1 commit into
jcadhoc wants to merge 1 commit into
Conversation
Exchange returns ('devolución para cambio') have to_refund=False, so the
return move did not reduce qty_received while the replacement receipt added
it again, leaving qty_received above the ordered qty (e.g. 14 vs 10).
Mirror the sale_stock_ux approach: tag exchange moves with is_exchange_move
and net them out in _compute_qty_received (subtract incoming exchange moves,
add back outgoing ones). Also add the stock.return.picking override so the
flag is set even without sale_stock_ux installed.
Contributor
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.

Problem
When doing an exchange return ("devolución para cambio") on a purchase receipt, the received quantity ends up higher than the ordered quantity (e.g. 14 received against 10 ordered).
Exchange return moves have
to_refund=False, so the return move does not reduceqty_received, while the replacement receipt adds it again.purchase_stock_uxhad no notion of exchange moves, so the two never netted out.Fix
Mirror the approach already shipping in
sale_stock_uxforqty_delivered:is_exchange_moveflag onstock.move(and keep it out of move merging).stock.return.pickingto tag exchange moves with the flag (and block exchange + "to refund" together), so it works even withoutsale_stock_uxinstalled._compute_qty_received, after the base computation, subtract incoming exchange moves (the replacement receipt) and add back outgoing ones, leaving the exchange neutral on the received qty.The "Returned" column stays at 0 for exchanges on purpose: an exchange is not a refund-return; the correction belongs in
qty_received.Test
Added
test_exchange_return.pyreproducing the flow: receive 10 → exchange-return 4 → receive replacement 4, assertingqty_received == 10(was 14).Task #65271.