diff options
| author | Arnold Moyaux <arm@odoo.com> | 2021-03-12 09:59:30 +0000 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2021-03-18 15:26:44 +0000 |
| commit | 16c9f192f605aadfb4b3fdea5030ce3579ebb0df (patch) | |
| tree | eb5ccb73130215040b4d073307c6c7e068e1333d /addons/mrp_subcontracting/models | |
| parent | 0ae22aa773f9343fc79937cceb5bf60c5fb3ba3c (diff) | |
[FIX] mrp_subcontracting, stock: Resupply Subcontractor on Order
Steps to reproduce the bug:
- Let's consider a consumable product P with a subcontracted BOM B
- Let's consider that B is subcontracted by a partner S and B has a storable component C
- C has the route Resupply Subcontractor on Order and has a partner SUP as supplier
- Create a purchase order PO with 1 P to S and confirm PO
- A delivery order DO1 is created with C to S
- Change the ordered quantity on PO and set 2 instead of 1
Bug:
DO1 was canceled and a new delivery order DO2 was created with only 1 C instead of 2
It happens due to merge move, when updating the PO line a new rule is
trigger and create the object in this order:
- Move Sub-Stock(finished) -> Subcontract Order -> Move Stock-Sub(comp)
Then the action_confirm is trigger and will run _merge_move
on object from left to right order. But when the move Sub-Stock is
merged, everything is write in the first move and the new move is
unlink. It result by canceling all the following object (so the new
subcontractor and the Move Stock-Sub). It was not an issue for the
subcontracting since the write of stock.move is overridden in order
to update the order quantity when the move quantity is updated.
However in this case the rule are not triggered in order to create
the moves that ressuply the subcontractor.
In order to avoid this mess, this PR prevent the merge in case of a
subcontracting move.
opw-2419222
closes odoo/odoo#68098
X-original-commit: 48f2bbb844502c91dce59e8d869b56df0960fd0a
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Co-authored-by: simongoffin <sig@odoo.com>
Diffstat (limited to 'addons/mrp_subcontracting/models')
| -rw-r--r-- | addons/mrp_subcontracting/models/stock_move.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/mrp_subcontracting/models/stock_move.py b/addons/mrp_subcontracting/models/stock_move.py index 45f5bcce5eb..00d492c0662 100644 --- a/addons/mrp_subcontracting/models/stock_move.py +++ b/addons/mrp_subcontracting/models/stock_move.py @@ -112,6 +112,7 @@ class StockMove(models.Model): def _action_confirm(self, merge=True, merge_into=False): subcontract_details_per_picking = defaultdict(list) + move_to_not_merge = self.env['stock.move'] for move in self: if move.location_id.usage != 'supplier' or move.location_dest_id.usage == 'supplier': continue @@ -128,10 +129,13 @@ class StockMove(models.Model): 'is_subcontract': True, 'location_id': move.picking_id.partner_id.with_company(move.company_id).property_stock_subcontractor.id }) + move_to_not_merge |= move for picking, subcontract_details in subcontract_details_per_picking.items(): picking._subcontracted_produce(subcontract_details) - res = super(StockMove, self)._action_confirm(merge=merge, merge_into=merge_into) + # We avoid merging move due to complication with stock.rule. + super(StockMove, move_to_not_merge)._action_confirm(merge=False) + res = super(StockMove, self - move_to_not_merge)._action_confirm(merge=merge, merge_into=merge_into) if subcontract_details_per_picking: self.env['stock.picking'].concat(*list(subcontract_details_per_picking.keys())).action_assign() return res |
