openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #05711
[Merge] lp:~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde into lp:ocb-addons
Alexandre Fayolle - camptocamp has proposed merging lp:~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde into lp:ocb-addons.
Requested reviews:
OpenERP Community Backports Team (ocb)
Related bugs:
Bug #1302630 in OpenERP Community Backports (Addons): "[trunk/7.0] document : search method overload breaks "order by" clause on ir.attachment object"
https://bugs.launchpad.net/ocb-addons/+bug/1302630
For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde/+merge/214486
[FIX] document: preserve order in search()
port of https://code.launchpad.net/~camptocamp/openobject-addons/7.0_fix-document-search-order-by_rde/+merge/214483 to OCB
--
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde/+merge/214486
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~camptocamp/ocb-addons/ocb-7.0-fix_1302630_document_search_order_by-rde into lp:ocb-addons.
=== modified file 'document/document.py'
--- document/document.py 2014-03-10 08:54:20 +0000
+++ document/document.py 2014-04-07 08:38:14 +0000
@@ -89,6 +89,11 @@
if not ids:
return 0 if count else []
+ # 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.
# 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.
@@ -108,7 +113,8 @@
for parent_id in visible_parent_ids:
ids.extend(parents[parent_id])
- return len(ids) if count else ids
+ 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:
Follow ups