diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 8b12ee82..4195a895 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -162,11 +162,16 @@ class AccountEasyReconcile(orm.Model): def _last_history(self, cr, uid, ids, name, args, context=None): result = {} - for history in self.browse(cr, uid, ids, context=context): - result[history.id] = False - if history.history_ids: - # history is sorted by date desc - result[history.id] = history.history_ids[0].id + # do a search() for retrieving the latest history line, + # as a read() will badly split the list of ids with 'date desc' + # and return the wrong result. + for reconcile_id in ids: + history_obj = self.pool['easy.reconcile.history'] + last_history = history_obj.search( + cr, uid, [('easy_reconcile_id', '=', reconcile_id)], + limit=1, order='date desc' + ) + result[reconcile_id] = last_history return result _columns = {