Add length check + retrieve first element from search result

This commit is contained in:
Matthieu Dietrich
2014-10-17 15:27:52 +02:00
parent 67f7ba24b6
commit c15f22cec9

View File

@@ -167,10 +167,14 @@ class AccountEasyReconcile(orm.Model):
# and return the wrong result.
history_obj = self.pool['easy.reconcile.history']
for reconcile_id in ids:
result[reconcile_id] = history_obj.search(
last_history = history_obj.search(
cr, uid, [('easy_reconcile_id', '=', reconcile_id)],
limit=1, order='date desc'
)
if len(last_history) > 0:
result[reconcile_id] = last_history[0]
else:
result[reconcile_id] = False
return result
_columns = {