From 6956ebbce6072fab44d11be79675b0cd72f6e029 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 27 Dec 2019 13:29:09 +0000 Subject: [PATCH] [FIX] mrp: unbuild with push rule - Create products A & B - Create a BOM: 1 unit of A to produce 1 unit of B - Create a Route which applies on products with the following Rule: Action: Push To Operation Type: YourCompany: Internal Transfers Source Location: WH/Stock Destination Location: WH/Stock/Shelf 1 Automatic Move: Automatic No Step Added - Apply the route to A - Create a MO for B, validate - Create an Unbuild Order for the MO created, validate The component (A) has a `stock.move` to WH/Stock/Shelf 1 but a `stock.move.line` to WH/Stock. This is because the `stock.move.line` is created when the quantity is set in: https://github.com/odoo/odoo/blob/98b1039705d5911946ed3b5180e4d114dc809ed4/addons/mrp/models/mrp_unbuild.py#L151 However, the `_run_push`, which only changes the `stock.move` location, is called on `_action_confirm` during the call to `_action_done`: https://github.com/odoo/odoo/blob/98b1039705d5911946ed3b5180e4d114dc809ed4/addons/mrp/models/mrp_unbuild.py#L152 The solution is to call `_action_confirm` before the creation of the `stock.move.line`. opw-2156132 closes odoo/odoo#42493 X-original-commit: ac0f43f704a988f11e4670e241380b76dc81f8fc Signed-off-by: Nicolas Martinelli (nim) --- addons/mrp/models/mrp_unbuild.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mrp/models/mrp_unbuild.py b/addons/mrp/models/mrp_unbuild.py index 23221ae28c7..8d3115af6a6 100644 --- a/addons/mrp/models/mrp_unbuild.py +++ b/addons/mrp/models/mrp_unbuild.py @@ -143,6 +143,7 @@ class MrpUnbuild(models.Model): consume_moves = self._generate_consume_moves() consume_moves._action_confirm() produce_moves = self._generate_produce_moves() + produce_moves._action_confirm() finished_move = consume_moves.filtered(lambda m: m.product_id == self.product_id) consume_moves -= finished_move