diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py
index 4971d849227..df80ac2ea9f 100644
--- a/addons/mrp/procurement.py
+++ b/addons/mrp/procurement.py
@@ -40,14 +40,6 @@ class procurement_order(osv.osv):
'production_id': fields.many2one('mrp.production', 'Manufacturing Order'),
}
- def _find_suitable_rule(self, cr, uid, procurement, context=None):
- rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
- if not rule_id:
- #if there isn't any specific procurement.rule defined for the product, we try to directly supply it from a supplier
- rule_id = self._search_suitable_rule(cr, uid, procurement, [('action', '=', 'manufacture'), ('location_id', '=', procurement.location_id.id)], context=context)
- rule_id = rule_id and rule_id[0] or False
- return rule_id
-
def _run(self, cr, uid, procurement, context=None):
if procurement.rule_id and procurement.rule_id.action == 'manufacture':
#make a manufacturing order for the procurement
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index e23ee0431ac..c2c5a053eab 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -1126,14 +1126,6 @@ class procurement_order(osv.osv):
'purchase_line_id': fields.many2one('purchase.order.line', 'Purchase Order'),
}
- def _find_suitable_rule(self, cr, uid, procurement, context=None):
- rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
- if not rule_id:
- #if there isn't any specific procurement.rule defined for the product, we try to directly supply it from a supplier
- rule_id = self._search_suitable_rule(cr, uid, procurement, [('action', '=', 'buy'), ('location_id', '=', procurement.location_id.id)], context=context)
- rule_id = rule_id and rule_id[0] or False
- return rule_id
-
def _run(self, cr, uid, procurement, context=None):
print "dans le run de purchase"
print procurement
diff --git a/addons/stock_complex_routes/test/dropship.yml b/addons/stock_complex_routes/test/dropship.yml
index 598a4c6a2b9..a9790ea5c9c 100644
--- a/addons/stock_complex_routes/test/dropship.yml
+++ b/addons/stock_complex_routes/test/dropship.yml
@@ -57,6 +57,11 @@
print 'procurement_order', procurement_order.state
print 'test', procurement_order.purchase_line_id.order_id
print 'test rule name', procurement_order.rule_id.name
+ print 'test route sequence', [(r.name, r.sequence) for r in procurement_order.route_ids]
+ rule_seq = []
+ for route in procurement_order.route_ids:
+ rule_seq += [(ru.name, ru.route_sequence, ru.sequence) for ru in route.pull_ids]
+ print '####RULES SEQ####', rule_seq
purchase_id = procurement_order.purchase_line_id.order_id.id
wf_service = netsvc.LocalService('workflow')
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index aeff85edd3f..6c1892bc18f 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -581,27 +581,34 @@ class procurement_order(osv.osv):
})
return d
+ def _find_parent_locations(self, cr, uid, procurement, context=None):
+ location = procurement.location_id
+ res = [location.id]
+ while location.location_id:
+ location = location.location_id
+ res.append(location.id)
+ return res
+
def _find_suitable_rule(self, cr, uid, procurement, context=None):
rule_id = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
if not rule_id:
- rule_id = self._search_suitable_rule(cr, uid, procurement, [('location_id', '=', procurement.location_id.id)], context=context) #action=move
+ #a rule defined on 'Stock' is suitable for a procurement in 'Stock\Bin A'
+ all_parent_location_ids = self._find_parent_locations(cr, uid, procurement, context=context)
+ rule_id = self._search_suitable_rule(cr, uid, procurement, [('location_id', 'in', all_parent_location_ids)], context=context)
rule_id = rule_id and rule_id[0] or False
return rule_id
def _search_suitable_rule(self, cr, uid, procurement, domain, context=None):
'''we try to first find a rule among the ones defined on the procurement order group and if none is found, we try on the routes defined for the product, and finally we fallback on the default behavior'''
- categ_obj = self.pool.get("product.category")
- categ_id = procurement.product_id.categ_id.id
- route_ids1 = [x.id for x in procurement.product_id.route_ids + procurement.product_id.categ_id.total_route_ids]
- route_ids2 = [x.id for x in procurement.route_ids]
- res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids1)], order = 'route_sequence, sequence', context=context)
+ product_route_ids = [x.id for x in procurement.product_id.route_ids + procurement.product_id.categ_id.total_route_ids]
+ procurement_route_ids = [x.id for x in procurement.route_ids]
+ res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', product_route_ids)], order = 'route_sequence, sequence', context=context)
if not res:
- res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids2)], order = 'route_sequence, sequence', context=context)
+ res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', procurement_route_ids)], order = 'route_sequence, sequence', context=context)
if not res:
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', '=', False)], order='sequence', context=context)
return res
-
class product_putaway_strategy(osv.osv):
_name = 'product.putaway'
_description = 'Put Away Strategy'
diff --git a/addons/stock_location/stock_location_data.xml b/addons/stock_location/stock_location_data.xml
index 5cbb9d863e4..cc83be2dc85 100644
--- a/addons/stock_location/stock_location_data.xml
+++ b/addons/stock_location/stock_location_data.xml
@@ -84,26 +84,29 @@
+
- Your Company: Stock → Customers
+ Your Company: Output → Customers
move
-
+
make_to_order
+
- Your Company: Stock → Stock
+ Your Company: Input → Output
move
-
-
+
+
make_to_stock
+