From eddda89052ef64858bfff7610c1be72f33985b2e Mon Sep 17 00:00:00 2001 From: Florian Damhaut <flda@odoo.com> Date: Tue, 14 Dec 2021 14:20:29 +0000 Subject: [PATCH] [FIX] mrp: Context irrelevant of hidden parameters for stock_mrp Step to reproduce: - Inventory > Configuration > Operations Types > Manufacturing (or any other operation type with code 'mrp_operation') - Change 'Type of Operation' to 'Receipt' (or any other but 'manufacturing') - Uncheck box field 'Use Existing Lots/Serial Numbers' - Change 'Type of Operation' back to 'Manufacturing' - Set correct value for 'Default Source Location' (type Receipt changed the value to 'Vendor', need to fix it) - Create a storable product with the route 'Manufacture' selected. - Create a BoM for this product, with a component tracked by lot (Add quantity to component) - Create a MO for the product > Confirm > Check Availability Current Behaviour : Quantity are reserved, but the lot_ids are not visible The behaviour is due to the fact that hidden parameters still have effect when they should act as their default value. To ensure it's the case, they are set back to their original value when the user switch between configuration to avoid ending in a wrongful configuration. Behaviour after PR : Lot ids are shown no matter the hidden configuration of picking type opw-2680370 closes odoo/odoo#81290 Signed-off-by: Arnold Moyaux <arm@odoo.com> --- addons/mrp/models/stock_picking.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/stock_picking.py b/addons/mrp/models/stock_picking.py index bce69712c769..ed1e574a855f 100644 --- a/addons/mrp/models/stock_picking.py +++ b/addons/mrp/models/stock_picking.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import fields, models, api class StockPickingType(models.Model): @@ -50,6 +50,12 @@ class StockPickingType(models.Model): def get_mrp_stock_picking_action_picking_type(self): return self._get_action('mrp.mrp_production_action_picking_deshboard') + @api.onchange('code') + def _onchange_code(self): + if self.code == 'mrp_operation': + self.use_create_lots = True + self.use_existing_lots = True + class StockPicking(models.Model): _inherit = 'stock.picking' -- GitLab