Commit 7a8a2cd2 authored by Jérome Perrin's avatar Jérome Perrin

pdm: fix Organisation_jumpToRelatedObjectList

getRelatedValueList seems to have changed in behavior at some point, when
passed multiple base_category_list, it only returns document that are member
of all the categories. Since this API is inneficient here (it searchs catalog
unrestrictedly and then apply check one by one the documents in python), we
change to use portal_catalog which is much better suited for this kind of
queries.
parent f084c646
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
Jump from Organisation to its related objects (but only if used as Jump from Organisation to its related objects (but only if used as
source* or destination* categories) of the same portal type and source* or destination* categories) of the same portal type and
displayed using the module view displayed using the module view
XXX: move this code to erp5_core if needed elsewhere?
""" """
portal = context.getPortalObject() portal = context.getPortalObject()
# XXX: Seems there is no other better way to get the Arrow # XXX: Seems there is no other better way to get the Arrow
# destination/section categories... # destination/section categories...
base_category_list = [] base_category_uid_list = []
for arrow_property in portal.portal_property_sheets.Arrow.contentValues(): for arrow_property in portal.portal_property_sheets.Arrow.contentValues():
if arrow_property.getPortalType() != 'Category Property': if arrow_property.getPortalType() != 'Category Property':
continue continue
...@@ -17,12 +15,15 @@ for arrow_property in portal.portal_property_sheets.Arrow.contentValues(): ...@@ -17,12 +15,15 @@ for arrow_property in portal.portal_property_sheets.Arrow.contentValues():
arrow_property_title = arrow_property.getTitle() arrow_property_title = arrow_property.getTitle()
if (arrow_property_title.startswith('source') or if (arrow_property_title.startswith('source') or
arrow_property_title.startswith('destination')): arrow_property_title.startswith('destination')):
base_category_list.append(arrow_property_title) base_category_uid_list.append(portal.portal_categories[arrow_property_title].getUid())
related_object_list = context.getRelatedValueList( related_object_list = context.getPortalObject().portal_catalog(
checked_permission='View', portal_type=portal_type,
base_category_list=base_category_list, **{
portal_type=portal_type) 'category.category_uid': context.getUid(),
'category.base_category_uid': base_category_uid_list,
}
)
if not related_object_list: if not related_object_list:
return context.Base_redirect(form_id, keep_items=dict( return context.Base_redirect(form_id, keep_items=dict(
......
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