diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 2264891a7cc..172fd473e5f 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -166,17 +166,23 @@ class PickingType(models.Model): def _onchange_picking_code(self): warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.company_id.id)], limit=1) stock_location = warehouse.lot_stock_id + self.show_operations = self.code != 'incoming' and self.user_has_groups( + 'stock.group_production_lot,' + 'stock.group_stock_multi_locations,' + 'stock.group_tracking_lot' + ) if self.code == 'incoming': self.default_location_src_id = self.env.ref('stock.stock_location_suppliers').id self.default_location_dest_id = stock_location.id elif self.code == 'outgoing': self.default_location_src_id = stock_location.id self.default_location_dest_id = self.env.ref('stock.stock_location_customers').id - self.show_operations = self.code != 'incoming' and self.user_has_groups( - 'stock.group_production_lot,' - 'stock.group_stock_multi_locations,' - 'stock.group_tracking_lot' - ) + elif self.code == 'internal' and not self.user_has_groups('stock.group_stock_multi_locations'): + return { + 'warning': { + 'message': _('You need to activate storage locations to be able to do internal operation types.') + } + } @api.onchange('company_id') def _onchange_company_id(self):