[FIX] document : keep order during the search of ir.attachment
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user