From 16fa24d52258245af4ee9100666bae6ebe664046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Wed, 7 Jan 2015 12:01:54 +0100 Subject: [PATCH] [FIX] document : keep order during the search of ir.attachment --- addons/document/document.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/document/document.py b/addons/document/document.py index 3d043e0c2f4..86eea66cab2 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -94,7 +94,6 @@ class document_file(osv.osv): ids = super(document_file, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=False) if not ids: return 0 if count else [] - # Filter out documents that are in directories that the user is not allowed to read. # Must use pure SQL to avoid access rules exceptions (we want to remove the records, # not fail), and the records have been filtered in parent's search() anyway. @@ -110,10 +109,13 @@ class document_file(osv.osv): visible_parent_ids = self.pool.get('document.directory').search(cr, uid, [('id', 'in', list(parent_ids))]) # null parents means allowed + orig_ids = ids # save the ids, to keep order ids = parents.get(None,[]) for parent_id in visible_parent_ids: ids.extend(parents[parent_id]) + # sort result according to the original sort ordering + ids = [id for id in orig_ids if id in ids] return len(ids) if count else ids def copy(self, cr, uid, id, default=None, context=None):