Confirming a PO with a customer as delivery address does not work
To reproduce the issue:
1. In Settings, enable "Multi-Locations"
2. Create two products P_finished, P_compo
- P_finished:
- Add a vendor V
3. Create a bill of materials:
- Product: P_finished
- Type: Subcontract
- Subcontractor: V
- Components: 1 x P_compo
4. Create a PO:
- Vendor: V
- Products: 1 x P_finished
- Deliver To: Dropship
- Drop Ship Address: a customer
5. Confirm the PO
Error: a validation error is displayed: "[...] a mandatory field is not
set. [...] Model: Production Order (mrp.production), Field: Operation
Type (picking_type_id)"
When confirming the PO, we extract some values of the subcontracted SM
to create a MO:
https://github.com/odoo/odoo/blob/829369d3ca0530f1aad0599fbb1598810a928cc3/addons/mrp_subcontracting/models/stock_picking.py#L105-L117
However, because the SM is not created from the SO, it does not have any
`sale_line_id`. And, because its a dropshipped one, neither the SM nor
its picking type has a defined warehouse. As a result, `_get_warehouse`
does not return anything and we can't define the `picking_type_id` of
the MO. This is the reason why the error will be triggered on its
creation.
OPW-2922546
closesodoo/odoo#99223
X-original-commit: 28a20daab6a7097ecd26bf66eeb80b2f5ad294a8
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>