From c15f22cec9322dcf8b0200a05990582020eb75e2 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 17 Oct 2014 15:27:52 +0200 Subject: [PATCH] Add length check + retrieve first element from search result --- account_easy_reconcile/easy_reconcile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index d3865477..c2c0cb93 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -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 = {