diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 90868700c17..57357d6850a 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1054,8 +1054,9 @@ class mrp_production(osv.osv): def _get_raw_material_procure_method(self, cr, uid, product, context=None): '''This method returns the procure_method to use when creating the stock move for the production raw materials''' + warehouse_obj = self.pool['stock.warehouse'] try: - mto_route = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'route_warehouse0_mto')[1] + mto_route = warehouse_obj._get_mto_route(cr, uid, context=context) except: return "make_to_stock" routes = product.route_ids + product.categ_id.total_route_ids diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index c0fc9c5cbcf..d117659c123 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -288,6 +288,7 @@ class sale_order_line(osv.osv): context = context or {} product_uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') + warehouse_obj = self.pool['stock.warehouse'] warning = {} #UoM False due to hack which makes sure uom changes price, ... in product_id_change res = self.product_id_change(cr, uid, ids, pricelist, product, qty=qty, @@ -311,14 +312,14 @@ class sale_order_line(osv.osv): #determine if the product is MTO or not (for a further check) isMto = False if warehouse_id: - warehouse = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context=context) + warehouse = warehouse_obj.browse(cr, uid, warehouse_id, context=context) for product_route in product_obj.route_ids: if warehouse.mto_pull_id and warehouse.mto_pull_id.route_id and warehouse.mto_pull_id.route_id.id == product_route.id: isMto = True break else: try: - mto_route_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'route_warehouse0_mto').id + mto_route_id = warehouse_obj._get_mto_route(cr, uid, context=context) except: # if route MTO not found in ir_model_data, we treat the product as in MTS mto_route_id = False