[FIX] document: complete previous fix, restore sort order after filtering
authorOlivier Dony <odo@openerp.com>
Wed, 22 Aug 2012 09:17:17 +0000 (11:17 +0200)
committerOlivier Dony <odo@openerp.com>
Wed, 22 Aug 2012 09:17:17 +0000 (11:17 +0200)
bzr revid: odo@openerp.com-20120822091717-lwwfla9cqzlolw6h

addons/document/document.py

index 9011eaf..853524c 100644 (file)
@@ -188,6 +188,7 @@ class document_file(osv.osv):
 
         # Work with a set, as list.remove() is prohibitive for large lists of documents
         # (takes 20+ seconds on a db with 100k docs during search_count()!)
+        orig_ids = ids
         ids = set(ids)
 
         # Filter out documents that are in directories that the user is not allowed to read.
@@ -202,7 +203,9 @@ class document_file(osv.osv):
             if parent_id in disallowed_parents:
                 ids.remove(doc_id)
 
-        return len(ids) if count else list(ids)
+        # sort result according to the original sort ordering
+        result = [id for id in orig_ids if id in ids]
+        return len(result) if count else result
 
     def copy(self, cr, uid, id, default=None, context=None):
         if not default: