From d108db36ca2974179ded929370ea45a106f2e08c Mon Sep 17 00:00:00 2001 From: "Touati Djamel (otd)" Date: Wed, 6 Jul 2022 09:51:52 +0000 Subject: [PATCH] [FIX] mrp: prevent the creation of component SN if option is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Go to Inventory→ Configuration→ Warehouse Management →Operations Types - Go inside “Manufacturing”, and disable the checkbox “Create New Lots/Serial Numbers for Components” under the traceability section - create a MO with a traceable component - Confirm the MO Problem: You can create a new SN for the component without any warning, while the user is supposed to be blocked by a user error: https://github.com/odoo/odoo/blob/master/addons/mrp/models/stock_lot.py#L11-L16 The solution: We need to add the `active_mo_id` key in the context so that the user error will be triggered opw-2900256 closes odoo/odoo#96648 X-original-commit: 6d0ddc388d1c389e1911a6bb1c59c252870da1a7 Signed-off-by: Arnold Moyaux (arm) Signed-off-by: Djamel Touati (otd) --- addons/mrp/views/stock_move_views.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/addons/mrp/views/stock_move_views.xml b/addons/mrp/views/stock_move_views.xml index 31a765aded7..c86cc44561e 100644 --- a/addons/mrp/views/stock_move_views.xml +++ b/addons/mrp/views/stock_move_views.xml @@ -21,6 +21,9 @@ Consumed + + + @@ -40,6 +43,23 @@ + + stock.move.line.operation.tree.finished + stock.move.line + + + + { + 'active_mo_id': parent.raw_material_production_id, + 'active_picking_id': picking_id, + 'default_company_id': parent.company_id, + 'default_product_id': parent.product_id, + } + + + + + stock.move.line.search stock.move.line