From 8ea2a7555b725048791e1bf5bbf1f6db05f7a7cc Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 26 Sep 2013 10:02:50 +0200 Subject: [PATCH] [IMP] Give priority to product and product category routes bzr revid: jco@openerp.com-20130926080250-p0g0nd6ha28upbyj --- addons/stock_location/stock_location.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py index ca9634b120a..96bcc7f68dd 100644 --- a/addons/stock_location/stock_location.py +++ b/addons/stock_location/stock_location.py @@ -154,10 +154,13 @@ class procurement_order(osv.osv): '''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_ids = [x.id for x in procurement.route_ids + procurement.product_id.route_ids + procurement.product_id.categ_id.total_route_ids] - res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], order = 'route_sequence, sequence', context=context) + 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) if not res: - res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', '=', False)], order='sequence', context=context) + res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids2)], 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