From 81e198aa5d43fe28cc0b5e9af5279db06559244f Mon Sep 17 00:00:00 2001 From: Arnaud Baes Date: Thu, 19 Sep 2019 09:53:29 +0000 Subject: [PATCH] [IMP] stock: Warning on internal picking types. As there's technically no way to hide partially a selection field, we raise a warning when the user set a `stock.picking.type` as internal without having the setting `stock.group_stock_multilocations` enabled. closes odoo/odoo#37129 Taskid: BugsLogistics Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/stock_picking.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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):