odoo/odoo#265452
Created by fw-bot
Statuses:
- legal/cla: Contributor License Agreement check
- ci/runbot: Odoo Test Suite
- ci/upgrade_enterprise: Test upgrades for enterprise master
- ci/template: (runtime 1251s)
- ci/style: Optional style check. Ignore it only if strictly necessary.
- ci/security: Required security check. Can only be ignored by security team.
- ci/l10n: (runtime 24s)
- ci/documentation: (runtime 1229s)
- ci/design-theme: (runtime 2190s)
- label
- odoo-dev:saas-19.3-saas-18.3-opw-5479900-subcontracting_location-qucol-527900-fw
- head
- 00f2eae1fa2a82088a31accec074ea3f11e325d4
- merged
- 15 hours ago by Quentin Colla (qucol)
| odoo/odoo | |
|---|---|
| saas-18.3 | #245905 |
| saas-18.4 | #264386 |
| 19.0 | #264798 |
| saas-19.1 | #265071 |
| saas-19.2 | #265259 |
| saas-19.3 | #265452 |
| master | #265627 missing r+ |
[FIX] mrp_subcontracting: use correct location for return for exchange
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.
<img width="1254" height="257" alt="5479900" src="https://github.com/user-attachments/assets/c7e6d392-8328-4a03-a71e-466e768f448b" />
Steps to reproduce
- Install MRP Subcontracting (
mrp_subcontracting) and Purchase (purchase) - In Settings, enable Subcontracting
- Create a Product P and a subcontracting BoM with Subcontractor S
- Create a Request for Quotation
- Vendor: Subcontractor S
- Product: Product P (any quantity > 0)
- Confirm the RFQ, receive the PO, validate the picking
- 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
- Validate the two new pickings
- In Inventory > Reporting > Moves History, the very last
stock.move.linehas 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.