From ec0234e12f83037161a751cc5d3beab0bf42157d Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Wed, 25 Oct 2017 11:58:37 +0200 Subject: [PATCH] [FIX] stock: location created with wrong company. When creating a new company the system will generate a new warehouse, its location and its routes. However the default company is the company that the user is using. For example user is in company_1 and creates company_2 it will create: 'company_2: Receipt in 1 step' and the company_id on it will be company_1 This commit completes the dict for create routes in order to introduce the key for company_id instead of using default value. --- addons/stock/models/stock_warehouse.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index 27cfa9b5b02..800d8af3c11 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -462,6 +462,7 @@ class Warehouse(models.Model): 'name': self._format_routename(route_type=route_type), 'product_categ_selectable': True, 'product_selectable': False, + 'company_id': self.company_id.id, 'sequence': 10, } @@ -482,7 +483,9 @@ class Warehouse(models.Model): 'product_selectable': True, 'product_categ_selectable': True, 'supplied_wh_id': self.id, - 'supplier_wh_id': supplier_warehouse.id} + 'supplier_wh_id': supplier_warehouse.id, + 'company_id': self.company_id.id, + } def _get_crossdock_route_values(self): return { @@ -491,6 +494,7 @@ class Warehouse(models.Model): 'product_selectable': True, 'product_categ_selectable': True, 'active': self.delivery_steps != 'ship_only' and self.reception_steps != 'one_step', + 'company_id': self.company_id.id, 'sequence': 20} # Pull / Push tools @@ -506,7 +510,9 @@ class Warehouse(models.Model): 'location_dest_id': routing.dest_loc.id, 'auto': 'manual', 'picking_type_id': routing.picking_type.id, - 'warehouse_id': self.id} + 'warehouse_id': self.id, + 'company_id': self.company_id.id, + } route_push_values.update(values or {}) route_push_values.update(push_values or {}) push_rules_list.append(route_push_values) @@ -518,6 +524,7 @@ class Warehouse(models.Model): 'picking_type_id': routing.picking_type.id, 'procure_method': first_rule is True and 'make_to_stock' or 'make_to_order', 'warehouse_id': self.id, + 'company_id': self.company_id.id, 'propagate': routing.picking_type != self.pick_type_id, } route_pull_values.update(values or {})