[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:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user