[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 a35df8d371

closes odoo/odoo#30844
This commit is contained in:
Arnold Moyaux
2019-02-07 09:05:19 +00:00
parent 37220d02a4
commit c47dc928f6
2 changed files with 6 additions and 0 deletions
+5
View File
@@ -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)
+1
View File
@@ -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,
}