From 96ac5c077060e87490a94520f19fa478d60336a4 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Fri, 19 Apr 2024 12:06:47 +0200 Subject: [PATCH] [FIX] mrp: respect picking type option The `use_create_components_lots` option of manufacturing picking type was never read as the context to get the active production order was not always specified. Also, this field was not taken into account to display or not the 'generate serial' and import 'lot buttons' closes odoo/odoo#162581 Related: odoo/enterprise#61137 Signed-off-by: Quentin Wolfs (quwo) --- addons/mrp/models/stock_move.py | 10 ++++++++++ addons/mrp/views/mrp_production_views.xml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index eb699778efe..0fb50d8d362 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -245,6 +245,16 @@ class StockMove(models.Model): super()._compute_show_info() self.filtered(lambda m: m.byproduct_id or m in self.production_id.move_finished_ids).show_quant = False + @api.depends('picking_type_id.use_create_components_lots') + def _compute_display_assign_serial(self): + super()._compute_display_assign_serial() + for move in self: + if move.display_import_lot \ + and move.raw_material_production_id \ + and not move.raw_material_production_id.picking_type_id.use_create_components_lots: + move.display_import_lot = False + move.display_assign_serial = False + @api.onchange('product_uom_qty') def _onchange_product_uom_qty(self): if self.raw_material_production_id and self.has_tracking == 'none': diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index 560c5864325..a04a31772a7 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -363,7 +363,7 @@