[FIX] stock: add warning when creating second warehouse

Add a warning to explain that create a second
warehouse will activate the multi-location automatically.

task-2439909

X-original-commit: 4964a9482b8b195f5b629ea5c91f7d7bfcce2163
This commit is contained in:
Rémy Voet (ryv)
2021-02-17 17:55:31 +00:00
parent 08d2b84674
commit 1df4969d23
4 changed files with 28 additions and 10 deletions
@@ -77,10 +77,10 @@ class TestSaleMrpProcurement(TransactionCase):
self.env.ref('stock.route_warehouse0_mto').active = True
# Create warehouse
self.customer_location = self.env['ir.model.data'].xmlid_to_res_id('stock.stock_location_customers')
warehouse_form = Form(self.env['stock.warehouse'])
warehouse_form.name = 'Test Warehouse'
warehouse_form.code = 'TWH'
self.warehouse = warehouse_form.save()
self.warehouse = self.env['stock.warehouse'].create({
'name': 'Test Warehouse',
'code': 'TWH'
})
self.uom_unit = self.env.ref('uom.product_uom_unit')
+6
View File
@@ -7958,3 +7958,9 @@ msgstr ""
#, python-format
msgid "You can't desactivate the multi-location if you have more than once warehouse by company"
msgstr ""
#. module: stock
#: code:addons/stock/models/stock_warehouse.py:0
#, python-format
msgid "Creating a new warehouse will automatically activate the Storage Locations setting"
msgstr ""
+12
View File
@@ -92,6 +92,18 @@ class Warehouse(models.Model):
('warehouse_code_uniq', 'unique(code, company_id)', 'The short name of the warehouse must be unique per company!'),
]
@api.onchange('company_id')
def _onchange_company_id(self):
group_user = self.env.ref('base.group_user')
group_stock_multi_warehouses = self.env.ref('stock.group_stock_multi_warehouses')
if group_stock_multi_warehouses not in group_user.implied_ids:
return {
'warning': {
'title': _('Warning'),
'message': _('Creating a new warehouse will automatically activate the Storage Locations setting')
}
}
@api.model
def create(self, vals):
# create view location for warehouse then create all locations
@@ -13,12 +13,12 @@ class TestCrossdock(common.TransactionCase):
supplier_crossdock = self.env['res.partner'].create({'name': "Crossdocking supplier"})
# I first create a warehouse with pick-pack-ship and reception in 2 steps
wh_f = Form(self.env['stock.warehouse'])
wh_f.name = 'WareHouse PickPackShip'
wh_f.code = 'whpps'
wh_f.reception_steps = 'two_steps'
wh_f.delivery_steps = 'pick_pack_ship'
wh_pps = wh_f.save()
wh_pps = self.env['stock.warehouse'].create({
'name': 'WareHouse PickPackShip',
'code': 'whpps',
'reception_steps': 'two_steps',
'delivery_steps': 'pick_pack_ship',
})
# Check that cross-dock route is active
self.assertTrue(wh_pps.crossdock_route_id.active,