[FIX] mrp_subcontracting: use correct location for return for exchange#265452
Closed
fw-bot wants to merge 1 commit into
Closed
Conversation
Contributor
Contributor
Author
|
@qucol-odoo cherrypicking of pull request #245905 failed. stdout: Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
## Issue
When making a request for quotation for a subcontracted product and
returning the delivery "for exchange", the new incoming delivery does
not have the correct destination. Instead of having the stock of the
user, the destination of the new incoming delivery is the same as its
source: the subcontracting location.
## Steps to reproduce
1. Install MRP Subcontracting (`mrp_subcontracting`) and Purchase (`purchase`)
2. In Settings, enable *Subcontracting*
3. Create a Product P and a subcontracting BoM with Subcontractor S
4. Create a Request for Quotation
- Vendor: Subcontractor S
- Product: Product P (any quantity > 0)
5. Confirm the RFQ, receive the PO, validate the picking
6. On the validated picking, click *Return*, set the quantity of products
to return, and click *Return for Exchange*
- This creates two new pickings, one to return the product(s) we
received, and one to receive new products
7. Validate the two new pickings
8. **In Inventory > Reporting > Moves History, the very last `stock.move.line`
has the same location in the *From* (`location_id`) and the
*To* (`location_dest_id`) columns**
## Cause
The `location_dest_id` of the new `stock.move` is updated in
`StockReturnPickingLine._prepare_move_default_values`.
https://github.com/odoo/odoo/blob/fb534f1eadcb8ef74e2ee6fd5b68872dddb978e3/addons/mrp_subcontracting/wizard/stock_picking_return.py#L20-L25
The condition added by odoo@5404b426aac9
sets the destination of all returned subcontracted moves to the subcontractor
location. This is incorrect when using "return for exchange", as in this
case, the return move is directed towards the user's stock. In fact,
when using "return for exchange", the following pickings are created:
| id | name | return_id | |
|:--:|--------------|:---------:|---|
| 1 | WH/IN/00001 | | Initial RFQ delivery |
| 2 | WH/OUT/00001 | 1 | Return of the initial RFQ delivery |
| 3 | WH/IN/00002 | 2 | New products delivery to replace the initial delivery. The stock.move.line of this stock.picking has a wrong `location_dest_id` |
## Fix
In the context of return for exchanges, the returned item must be directed
to the *Subcontracting Location* while the new item must be directed to
the *Stock*. In the `_prepare_move_default_values`, we should only set
the `location_dest_it` to the subcontractor location for outgoing pickings.
opw-5479900
X-original-commit: d6e742c
1142f64 to
00f2eae
Compare
Contributor
|
Only merging the test, as the fix is no longer required in 19.3 because the exchange move has @robodoo r+ |
robodoo
pushed a commit
that referenced
this pull request
May 20, 2026
## Issue
When making a request for quotation for a subcontracted product and
returning the delivery "for exchange", the new incoming delivery does
not have the correct destination. Instead of having the stock of the
user, the destination of the new incoming delivery is the same as its
source: the subcontracting location.
## Steps to reproduce
1. Install MRP Subcontracting (`mrp_subcontracting`) and Purchase (`purchase`)
2. In Settings, enable *Subcontracting*
3. Create a Product P and a subcontracting BoM with Subcontractor S
4. Create a Request for Quotation
- Vendor: Subcontractor S
- Product: Product P (any quantity > 0)
5. Confirm the RFQ, receive the PO, validate the picking
6. On the validated picking, click *Return*, set the quantity of products
to return, and click *Return for Exchange*
- This creates two new pickings, one to return the product(s) we
received, and one to receive new products
7. Validate the two new pickings
8. **In Inventory > Reporting > Moves History, the very last `stock.move.line`
has the same location in the *From* (`location_id`) and the
*To* (`location_dest_id`) columns**
## Cause
The `location_dest_id` of the new `stock.move` is updated in
`StockReturnPickingLine._prepare_move_default_values`.
https://github.com/odoo/odoo/blob/fb534f1eadcb8ef74e2ee6fd5b68872dddb978e3/addons/mrp_subcontracting/wizard/stock_picking_return.py#L20-L25
The condition added by 5404b426aac9
sets the destination of all returned subcontracted moves to the subcontractor
location. This is incorrect when using "return for exchange", as in this
case, the return move is directed towards the user's stock. In fact,
when using "return for exchange", the following pickings are created:
| id | name | return_id | |
|:--:|--------------|:---------:|---|
| 1 | WH/IN/00001 | | Initial RFQ delivery |
| 2 | WH/OUT/00001 | 1 | Return of the initial RFQ delivery |
| 3 | WH/IN/00002 | 2 | New products delivery to replace the initial delivery. The stock.move.line of this stock.picking has a wrong `location_dest_id` |
## Fix
In the context of return for exchanges, the returned item must be directed
to the *Subcontracting Location* while the new item must be directed to
the *Stock*. In the `_prepare_move_default_values`, we should only set
the `location_dest_it` to the subcontractor location for outgoing pickings.
opw-5479900
closes #265452
X-original-commit: d6e742c
Signed-off-by: Quentin Colla (qucol) <qucol@odoo.com>
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.

Issue
When making a request for quotation for a subcontracted product and returning the delivery "for exchange", the new incoming delivery does not have the correct destination. Instead of having the stock of the user, the destination of the new incoming delivery is the same as its source: the subcontracting location.
Steps to reproduce
mrp_subcontracting) and Purchase (purchase)stock.move.linehas the same location in the From (location_id) and the To (location_dest_id) columnsCause
The
location_dest_idof the newstock.moveis updated inStockReturnPickingLine._prepare_move_default_values.odoo/addons/mrp_subcontracting/wizard/stock_picking_return.py
Lines 20 to 25 in fb534f1
The condition added by 5404b426aac9 sets the destination of all returned subcontracted moves to the subcontractor location. This is incorrect when using "return for exchange", as in this case, the return move is directed towards the user's stock. In fact, when using "return for exchange", the following pickings are created:
location_dest_idFix
In the context of return for exchanges, the returned item must be directed to the Subcontracting Location while the new item must be directed to the Stock. In the
_prepare_move_default_values, we should only set thelocation_dest_itto the subcontractor location for outgoing pickings.opw-5479900
Forward-Port-Of: #265071
Forward-Port-Of: #245905