diff --git a/addons/stock/data/stock_data.xml b/addons/stock/data/stock_data.xml
index de931bd88c6..e46088b3585 100644
--- a/addons/stock/data/stock_data.xml
+++ b/addons/stock/data/stock_data.xml
@@ -52,6 +52,7 @@
transit
+
diff --git a/addons/stock/models/res_company.py b/addons/stock/models/res_company.py
index 039ffa5d302..2766272b554 100644
--- a/addons/stock/models/res_company.py
+++ b/addons/stock/models/res_company.py
@@ -35,6 +35,7 @@ class Company(models.Model):
'usage': 'transit',
'location_id': parent_location and parent_location.id or False,
'company_id': company.id,
+ 'active': False
})
company.write({'internal_transit_location_id': location.id})
diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py
index 080b77f94e0..c53d85393a4 100644
--- a/addons/stock/models/stock_warehouse.py
+++ b/addons/stock/models/stock_warehouse.py
@@ -238,13 +238,16 @@ class Warehouse(models.Model):
('active', '=', False)
])
if existing_route:
- existing_route.write({'active': True})
+ existing_route.toggle_active()
else:
warehouse.create_resupply_routes(to_add)
if to_remove:
- Route.search([('supplied_wh_id', '=', warehouse.id), ('supplier_wh_id', 'in', to_remove.ids)]).write({'active': False})
- # TDE FIXME: shouldn't we remove stock rules also ? because this could make them global (not sure)
-
+ to_disable_route_ids = Route.search([
+ ('supplied_wh_id', '=', warehouse.id),
+ ('supplier_wh_id', 'in', to_remove.ids),
+ ('active', '=', True)
+ ])
+ to_disable_route_ids.toggle_active()
return res
@api.model
@@ -586,6 +589,7 @@ class Warehouse(models.Model):
transit_location = internal_transit_location if supplier_wh.company_id == self.company_id else external_transit_location
if not transit_location:
continue
+ transit_location.active = True
output_location = supplier_wh.lot_stock_id if supplier_wh.delivery_steps == 'ship_only' else supplier_wh.wh_output_stock_loc_id
# Create extra MTO rule (only for 'ship only' because in the other cases MTO rules already exists)
if supplier_wh.delivery_steps == 'ship_only':
diff --git a/addons/stock/tests/test_move.py b/addons/stock/tests/test_move.py
index de1d19be976..2777fdfff0b 100644
--- a/addons/stock/tests/test_move.py
+++ b/addons/stock/tests/test_move.py
@@ -17,7 +17,9 @@ class StockMove(SavepointCase):
cls.transit_location = cls.env['stock.location'].search([
('company_id', '=', cls.env.company.id),
('usage', '=', 'transit'),
+ ('active', '=', False)
], limit=1)
+ cls.transit_location.active = True
cls.uom_unit = cls.env.ref('uom.product_uom_unit')
cls.uom_dozen = cls.env.ref('uom.product_uom_dozen')
cls.product = cls.env['product.product'].create({
diff --git a/addons/stock/views/stock_location_views.xml b/addons/stock/views/stock_location_views.xml
index 05f37ca6c6a..c9460ce5ca5 100644
--- a/addons/stock/views/stock_location_views.xml
+++ b/addons/stock/views/stock_location_views.xml
@@ -153,7 +153,6 @@
Locations
stock.location
ir.actions.act_window
- form
tree,form,qweb
diff --git a/addons/stock_account/tests/test_stockvaluation.py b/addons/stock_account/tests/test_stockvaluation.py
index 1da38b06a2c..d957440bd7c 100644
--- a/addons/stock_account/tests/test_stockvaluation.py
+++ b/addons/stock_account/tests/test_stockvaluation.py
@@ -641,7 +641,9 @@ class TestStockValuation(SavepointCase):
transit_location = self.env['stock.location'].search([
('company_id', '=', self.env.company.id),
('usage', '=', 'transit'),
+ ('active', '=', False)
], limit=1)
+ transit_location.active = True
move8 = self.env['stock.move'].create({
'name': 'Send 10 units in transit',
'location_id': self.stock_location.id,