use warehouse._get_mto_route to get the MTO route
authorAlexandre Fayolle <alexandre.fayolle@camptocamp.com>
Mon, 22 Sep 2014 12:20:45 +0000 (14:20 +0200)
committerJosse Colpaert <jco@odoo.com>
Tue, 30 Sep 2014 08:31:33 +0000 (10:31 +0200)
instead of using a custom lookup with a different implementation
closes #2608

pass context as a named argument

addons/mrp/mrp.py
addons/sale_stock/sale_stock.py

index 9086870..57357d6 100644 (file)
@@ -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
index c0fc9c5..d117659 100644 (file)
@@ -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