[IMP] Push rules should try to find routes on warehouse first before searching anything
bzr revid: jco@openerp.com-20140403155735-y357mj3gtp7j3x7i
This commit is contained in:
parent
1ff8b73671
commit
d45fd02abd
|
@ -695,6 +695,7 @@ class purchase_order(osv.osv):
|
|||
'procurement_id': False,
|
||||
'origin': order.name,
|
||||
'route_ids': order.picking_type_id.warehouse_id and [(6, 0, [x.id for x in order.picking_type_id.warehouse_id.route_ids])] or [],
|
||||
'warehouse_id':order.picking_type_id.warehouse_id.id,
|
||||
}
|
||||
|
||||
diff_quantity = order_line.product_qty
|
||||
|
|
|
@ -136,7 +136,6 @@ class product_product(osv.osv):
|
|||
|
||||
moves_in = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_in))
|
||||
moves_out = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_out))
|
||||
|
||||
res = {}
|
||||
for id in ids:
|
||||
res[id] = {
|
||||
|
|
|
@ -1794,18 +1794,26 @@ class stock_move(osv.osv):
|
|||
# to receive goods without triggering the push rules again (which would duplicate chained operations)
|
||||
if not move.move_dest_id and not move.origin_returned_move_id:
|
||||
domain = [('location_from_id', '=', move.location_dest_id.id)]
|
||||
if move.warehouse_id:
|
||||
domain += ['|', ('warehouse_id', '=', move.warehouse_id.id), ('warehouse_id', '=', False)]
|
||||
|
||||
#priority goes to the route defined on the product and product category
|
||||
route_ids = [x.id for x in move.product_id.route_ids + move.product_id.categ_id.total_route_ids]
|
||||
rules = push_obj.search(cr, uid, domain + [('route_id', 'in', route_ids)], order='route_sequence, sequence', context=context)
|
||||
if not rules:
|
||||
#but if there's no rule matching, we try without filtering on routes
|
||||
rules = push_obj.search(cr, uid, domain, order='route_sequence, sequence', context=context)
|
||||
route_ids = []
|
||||
if move.warehouse_id:
|
||||
route_ids = [x.id for x in move.warehouse_id.route_ids]
|
||||
elif move.picking_type_id and move.picking_type_id.warehouse_id:
|
||||
route_ids = [x.id for x in move.picking_type_id.warehouse_id.route_ids]
|
||||
if route_ids:
|
||||
rules = push_obj.search(cr, uid, domain + [('route_id', 'in', route_ids)], order='route_sequence, sequence', context=context)
|
||||
if not rules:
|
||||
#but if there's no rule matching, we try without filtering on routes
|
||||
rules = push_obj.search(cr, uid, domain, order='route_sequence, sequence', context=context)
|
||||
if rules:
|
||||
rule = push_obj.browse(cr, uid, rules[0], context=context)
|
||||
push_obj._apply(cr, uid, rule, move, context=context)
|
||||
return True
|
||||
|
||||
|
||||
def _create_procurement(self, cr, uid, move, context=None):
|
||||
""" This will create a procurement order """
|
||||
|
|
Loading…
Reference in New Issue