Modify _last_history function to correctly retrieve the date

This commit is contained in:
Matthieu Dietrich
2014-10-17 13:03:27 +02:00
parent 43bbddce53
commit a1d7b1513e

View File

@@ -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 = {