Commit 80bdc192 authored by Jérome Perrin's avatar Jérome Perrin Committed by Aurel

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 8efc5382
......@@ -2,14 +2,12 @@
Jump from Organisation to its related objects (but only if used as
source* or destination* categories) of the same portal type and
displayed using the module view
XXX: move this code to erp5_core if needed elsewhere?
"""
portal = context.getPortalObject()
# XXX: Seems there is no other better way to get the Arrow
# destination/section categories...
base_category_list = []
base_category_uid_list = []
for arrow_property in portal.portal_property_sheets.Arrow.contentValues():
if arrow_property.getPortalType() != 'Category Property':
continue
......@@ -17,12 +15,15 @@ for arrow_property in portal.portal_property_sheets.Arrow.contentValues():
arrow_property_title = arrow_property.getTitle()
if (arrow_property_title.startswith('source') or
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(
checked_permission='View',
base_category_list=base_category_list,
portal_type=portal_type)
related_object_list = context.getPortalObject().portal_catalog(
portal_type=portal_type,
**{
'category.category_uid': context.getUid(),
'category.base_category_uid': base_category_uid_list,
}
)
if not related_object_list:
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