Commit 5c23c367 authored by Romain Courteaud's avatar Romain Courteaud

erp5_core: do one catalog call only

Catalog seems to correctly handle the OR parameters.

Do not lose the possible external `query` parameter.
parent e97990e9
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
kw.pop('relative_url', None) kw.pop('relative_url', None)
kw.pop('follow_up_uid', None) kw.pop('follow_up_uid', None)
portal_catalog=context.getPortalObject().portal_catalog
follow_up_related_document_list = portal_catalog(
portal_type=portal_type,
follow_up_uid=context.getUid(), **kw)
kw['query'] = Query(relative_url='%s/%%' % context.getRelativeUrl().replace('_', r'\_')) portal = context.getPortalObject()
if follow_up_related_document_list: portal_catalog = portal.portal_catalog
kw['query'] = ComplexQuery(
kw['query'], if portal_type is None:
Query(uid=[x.getUid() for x in follow_up_related_document_list]), portal_type = portal.getPortalDocumentTypeList() + portal.getPortalEmbeddedDocumentTypeList()
logical_operator='or')
return portal_catalog(portal_type=portal_type, limit=limit, **kw) document_query = ComplexQuery(
Query(follow_up_uid=context.getUid()),
Query(relative_url='%s/%%' % context.getRelativeUrl().replace('_', r'\_')),
logical_operator='or'
)
if query is None:
query = document_query
else:
query = ComplexQuery(
query,
document_query,
logical_operator='and'
)
return portal_catalog(
portal_type=portal_type,
query=query,
**kw)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>portal_type=(), limit=None, **kw</string> </value> <value> <string>portal_type=None, query=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment