diff --git a/addons/stock/models/res_config_settings.py b/addons/stock/models/res_config_settings.py index 3eca680cce7..57e9f0f4f40 100644 --- a/addons/stock/models/res_config_settings.py +++ b/addons/stock/models/res_config_settings.py @@ -92,3 +92,11 @@ class ResConfigSettings(models.TransientModel): ('delivery_steps', '=', 'ship_only')]) active = False warehouses.mapped('int_type_id').write({'active': active}) + + def execute(self): + res = super(ResConfigSettings, self).execute() + self.ensure_one() + if self.group_stock_multi_locations or self.group_stock_production_lot or self.group_stock_tracking_lot: + picking_types = self.env['stock.picking.type'].with_context(active_test=False).search([('show_operations', '=', False)]) + picking_types.write({'show_operations': True}) + return res diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index b5245e34dcd..1d9f26857e8 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -21,6 +21,11 @@ class PickingType(models.Model): _description = "Picking Type" _order = 'sequence, id' + def _default_show_operations(self): + return self.user_has_groups('stock.group_production_lot,' + 'stock.group_stock_multi_locations,' + 'stock.group_tracking_lot') + name = fields.Char('Operation Type', required=True, translate=True) color = fields.Integer('Color') sequence = fields.Integer('Sequence', help="Used to order the 'All Operations' kanban view") @@ -45,7 +50,7 @@ class PickingType(models.Model): 'Use Existing Lots/Serial Numbers', default=True, help="If this is checked, you will be able to choose the Lots/Serial Numbers. You can also decide to not put lots in this operation type. This means it will create stock with no lot or not put a restriction on the lot taken. ") show_operations = fields.Boolean( - 'Show Detailed Operations', default=False, + 'Show Detailed Operations', default=_default_show_operations, help="If this checkbox is ticked, the pickings lines will represent detailed stock operations. If not, the picking lines will represent an aggregate of detailed stock operations.") show_reserved = fields.Boolean( 'Show Reserved', default=True, help="If this checkbox is ticked, Odoo will show which products are reserved (lot/serial number, source location, source package).")