[IMP] stock: Optimize stock_move.setlast_tracking()
authorGuewen Baconnier <guewen.baconnier@camptocamp.com>
Tue, 16 Sep 2014 13:21:07 +0000 (15:21 +0200)
committerMartin Trigaux <mat@openerp.com>
Wed, 24 Sep 2014 14:41:29 +0000 (16:41 +0200)
commitb5c8ced8ecd7cf6a270565ee70d88ff6f53dcd54
treea0d1c656283c78b444c6b0d534cfa6766c59f989
parent126ba0a9a8a1aaaf959a1c2c0f235640e766a9de
[IMP] stock: Optimize stock_move.setlast_tracking()

When setlast_tracking is called on a large number of moves in a picking
(e.g.  when splitting moves in a picking), the time to complete grows
exponentially.  The reason is that it loops over all the moves of
a picking, even if it keeps only the last tracking.

The method now uses a search() with a limit so it doesn't need to browse
all the moves.

Added test to check the behaviour of setlast_tracking
Fixes #2448
addons/stock/__openerp__.py
addons/stock/stock.py
addons/stock/test/setlast_tracking.yml [new file with mode: 0644]