diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index 23c6f1ad220fecffa60b473102af4b7c45e3fdfb..bbd38f050798a27824f8a199265222d5b8cd9f1c 100755 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -40,6 +40,7 @@ from Products.ERP5Type.Utils import getPath from Products.ERP5Type.Document import newTempBase from Products.CMFCore.utils import getToolByName from copy import copy +from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain from Acquisition import aq_base, aq_inner, aq_parent, aq_self from zLOG import LOG @@ -50,6 +51,23 @@ from Products.PythonScripts.Utility import allow_class import random import md5 +class ObjectValuesWrapper: + """This class wraps objectValues so that objectValues behaves like portal_catalog. + """ + method_name = __name__ = 'objectValues' + + def __init__(self, context): + self.context = context + + def __call__(self, *args, **kw): + brain_list = [] + for obj in self.context.objectValues(*args, **kw): + brain = ZSQLBrain(None, None).__of__(obj) + brain.uid = obj.getUid() + brain.path = obj.getPath() + brain_list.append(brain) + return brain_list + def getAsList(a): l = [] for e in a: @@ -747,7 +765,7 @@ class ListBoxWidget(Widget.Widget): if hasattr(list_method, 'method_name'): if list_method.method_name == 'objectValues': - list_method = here.objectValues + list_method = ObjectValuesWrapper(here) kw = copy(params) kw['spec'] = filtered_meta_types else: