[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) <sle@openerp.com>
This commit is contained in:
Arnaud Baes
2019-09-19 13:36:00 +00:00
committed by Simon Lejeune
parent 5ac0c268b2
commit 81e198aa5d
+11 -5
View File
@@ -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):