summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2019-02-05 15:05:34 +0000
committerArnold Moyaux <arm@odoo.com>2019-02-07 09:05:19 +0000
commitc47dc928f6ec67f0e76c8b7907d7f62ae2452d89 (patch)
treeb2263ea7910a3b72987a10f23280923e10b85a57
parent37220d02a4d86e0f9a1d4658770a2d673605de13 (diff)
[FIX] stock: warehouse_selectable skip warehouse_ids
Usecase to reproduce: - Create a route with a warehouse_ids - Uncheck warehouse_selectable on route - Create a picking that use the route It should fail since the route is not applicable. It happens because _search_rule only check for route with warehouse_ids but it do not check for warehouse_selectable. We can't fix _search_rule since stock_warehouse.py creates multi step delivery and reception routes without warehouse_selectable thus it would break existing configuration. Instead create an onchange on warehouse_selectable that remove warehouse_ids on route. partial backport of commit a35df8d37170790257876a54aa54f2c3ab596c44 closes odoo/odoo#30844
-rw-r--r--addons/stock/models/stock_location.py5
-rw-r--r--addons/stock/models/stock_warehouse.py1
2 files changed, 6 insertions, 0 deletions
diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py
index bce2de0ecd2..b3903df88b7 100644
--- a/addons/stock/models/stock_location.py
+++ b/addons/stock/models/stock_location.py
@@ -170,6 +170,11 @@ class Route(models.Model):
categ_ids = fields.Many2many('product.category', 'stock_location_route_categ', 'route_id', 'categ_id', 'Product Categories')
warehouse_ids = fields.Many2many('stock.warehouse', 'stock_route_warehouse', 'route_id', 'warehouse_id', 'Warehouses')
+ @api.onchange('warehouse_selectable')
+ def _onchange_warehouse_selectable(self):
+ if not self.warehouse_selectable:
+ self.warehouse_ids = []
+
def write(self, values):
'''when a route is deactivated, deactivate also its pull and push rules'''
res = super(Route, self).write(values)
diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py
index 3394c3a1e7b..dc8766954de 100644
--- a/addons/stock/models/stock_warehouse.py
+++ b/addons/stock/models/stock_warehouse.py
@@ -467,6 +467,7 @@ class Warehouse(models.Model):
'name': self._format_routename(route_type=route_type),
'product_categ_selectable': True,
'product_selectable': False,
+ 'warehouse_selectable': True,
'company_id': self.company_id.id,
'sequence': 10,
}