[IMP] stock: give highest priority to routes set directly on the procurement.order (and thus on SO lines)
bzr revid: qdp-launchpad@openerp.com-20131022122958-gkm1unk3n4g7a3j0
This commit is contained in:
parent
441d0bc009
commit
492b4b568a
|
@ -134,15 +134,19 @@ class procurement_order(osv.osv):
|
|||
|
||||
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'''
|
||||
pull_obj = self.pool.get('procurement.rule')
|
||||
if procurement.warehouse_id:
|
||||
domain += [('warehouse_id', '=', procurement.warehouse_id.id)]
|
||||
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] + [x.id for x in procurement.warehouse_id.route_ids]
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', product_route_ids)], order = 'route_sequence, sequence', context=context)
|
||||
procurement_route_ids = [x.id for x in procurement.route_ids]
|
||||
warehouse_route_ids = [x.id for x in procurement.warehouse_id.route_ids]
|
||||
res = pull_obj.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', 'in', procurement_route_ids)], order = 'route_sequence, sequence', context=context)
|
||||
res = pull_obj.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', '=', False)], order='sequence', context=context)
|
||||
res = pull_obj.search(cr, uid, domain + [('route_id', 'in', warehouse_route_ids)], order='route_sequence, sequence', context=context)
|
||||
if not res:
|
||||
res = pull_obj.search(cr, uid, domain + [('route_id', '=', False)], order='sequence', context=context)
|
||||
return res
|
||||
|
||||
def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
|
|
Loading…
Reference in New Issue