OCA/OCB — pull request #47 by guewen (2014-09-16 14:17:55+00:00)
Title: 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.

When testing, I created a picking with 1 move of X units that I split in X
moves of 1 unit. It took with the original method:

* X = 10: 0.8 second
* X = 100: ~11 seconds
* X = 1000: ~340 seconds

Now:

* X = 10: 0.7 second
* X = 100: ~8 seconds
* X = 1000: ~90 seconds