Use grouped_slice helper.

issue3516
review10301002
This commit is contained in:
Sergi Almacellas Abellana committed 2014-07-17 18:56:57 +02:00
1 parent e6d46fce76
commit 2e9e62371a
1 file changed
+3 -4
+3 -4
View File
@@ -11,6 +11,7 @@ from trytond.pyson import Eval, Bool, If
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.wizard import Wizard, StateView, StateTransition, Button
from trytond.tools import grouped_slice
__all__ = ['Asset', 'AssetLine', 'AssetUpdateMove',
'CreateMovesStart', 'CreateMoves',
@@ -454,14 +455,12 @@ class Asset(Workflow, ModelSQL, ModelView):
pool = Pool()
Move = pool.get('account.move')
Line = pool.get('account.asset.line')
cursor = Transaction().cursor
moves = []
lines = []
for i in range(0, len(assets), cursor.IN_MAX):
asset_ids = [a.id for a in assets[i:i + cursor.IN_MAX]]
for asset_ids in grouped_slice(assets):
lines += Line.search([
('asset', 'in', asset_ids),
('asset', 'in', list(asset_ids)),
('date', '<=', date),
('move', '=', None),
])