[FIX] stock: multiple global push rules with same origin

When you have multiplle global push rules with the same source location,
a traceback is raised because the '_apply' method of
"stock.location.path" is called with more than one record, and doesn't
handle multiple record.

To fix this, we limit the number of records returned when a global rule
is searched to 1 (as for other 'search' of push rules in this file).

This bug has been introduced during migration in rev: https://github.com/odoo/odoo/commit/cb486d7eb6353a66eea2cb3610141b4f3a778791

opw-725874
This commit is contained in:
Pierre Masereel
2017-03-27 17:36:25 +02:00
parent 3d0db90dae
commit 7a039c730d
+1 -1
View File
@@ -376,7 +376,7 @@ class StockMove(models.Model):
rules = Push.search(domain + [('route_id', 'in', move.picking_id.picking_type_id.warehouse_id.route_ids.ids)], order='route_sequence, sequence', limit=1)
if not rules:
# if no specialized push rule has been found yet, we try to find a general one (without route)
rules = Push.search(domain + [('route_id', '=', False)], order='sequence')
rules = Push.search(domain + [('route_id', '=', False)], order='sequence', limit=1)
# Make sure it is not returning the return
if rules and (not move.origin_returned_move_id or move.origin_returned_move_id.location_dest_id.id != rules.location_dest_id.id):
rules._apply(move)