Merge pull request #58 from mdietrichc2c/fix_last_history_fetch

Modify _last_history function
This commit is contained in:
Guewen Baconnier
2014-10-20 15:46:59 +02:00

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.
history_obj = self.pool['easy.reconcile.history']
for reconcile_id in ids:
last_history = history_obj.search(
cr, uid, [('easy_reconcile_id', '=', reconcile_id)],
limit=1, order='date desc', context=context
)
result[reconcile_id] = last_history[0] if last_history else False
return result
_columns = {