diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 78d56994a780b651d84f768d5bc915fc0f37959f..fdffa623d83608d8ff212a3d4f9467e9cb7eca43 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -497,15 +497,16 @@ class ERP5TypeInformation(XMLObject, """ ec = createExpressionContext(ob) best_action = (), None - for action in self.getFilteredActionListFor(ob): + for action in self.getActionListFor(ob): if action.getReference() == view: - break + if action.test(ec): + break else: # In case that "view" (or "list") action is not present or not allowed, # find something that's allowed (of the same category, if possible). index = (action.getActionType().endswith('_' + view), -action.getFloatIndex()) - if best_action[0] < index: + if best_action[0] < index and action.test(ec): best_action = index, action else: action = best_action[1] @@ -519,6 +520,11 @@ class ERP5TypeInformation(XMLObject, __traceback_info__ = self.getId(), target return ob.restrictedTraverse(target) + security.declarePrivate('getActionListFor') + def getActionListFor(self, ob=None): + """Return all actions of the object""" + return self.getActionInformationList() + security.declarePrivate('getFilteredActionListFor') def getFilteredActionListFor(self, ob=None): """Return all actions applicable to the object""" diff --git a/product/ERP5Type/Tool/TypesTool.py b/product/ERP5Type/Tool/TypesTool.py index aa30db7e141f0dbdab09baa172523754b66ca7b0..975a1bb65e9d226add0db012faa406d1ac99edc0 100644 --- a/product/ERP5Type/Tool/TypesTool.py +++ b/product/ERP5Type/Tool/TypesTool.py @@ -42,6 +42,15 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool): zope.interface.implements(interfaces.IActionProvider) + security.declarePrivate('getActionListFor') + def getActionListFor(self, ob=None): + """Return all actions of the object""" + if ob is not None: + type_info = self.getTypeInfo(ob) + if type_info is not None: + return type_info.getActionListFor(ob) + return () + security.declarePrivate('getFilteredActionListFor') def getFilteredActionListFor(self, ob=None): """Return all actions applicable to the object""" diff --git a/product/ERP5Type/interfaces/action_provider.py b/product/ERP5Type/interfaces/action_provider.py index 2dc85c6f26d03c080d4abb376c008bc2be506f99..7b8c996b94a137bedf130c6528535fa9c2dc2bd1 100644 --- a/product/ERP5Type/interfaces/action_provider.py +++ b/product/ERP5Type/interfaces/action_provider.py @@ -53,6 +53,9 @@ class IAction(Interface): class IActionProvider(Interface): """ """ + def getActionListFor(ob): + """Return all actions of the object""" + def getFilteredActionListFor(ob): """Return all actions applicable to the object """ diff --git a/product/ERP5Type/patches/ActionsTool.py b/product/ERP5Type/patches/ActionsTool.py index 5a17272cd615f7b4e3a210f6579a662ace0cb6ce..a6888c4d48b2a978fe62ae76df0af8f4d1e39852 100644 --- a/product/ERP5Type/patches/ActionsTool.py +++ b/product/ERP5Type/patches/ActionsTool.py @@ -36,12 +36,13 @@ def listFilteredActionsFor(self, object=None): provider = getattr(self, provider_name) if providedBy(provider): actions.extend( provider.listActionInfos(object=object) ) - elif hasattr(provider, 'getFilteredActionListFor'): + elif hasattr(provider, 'getActionListFor'): from Products.ERP5Type.Utils import createExpressionContext ec = createExpressionContext(object) actions += sorted( (action.getActionInfo(ec) - for action in provider.getFilteredActionListFor(object)), + for action in provider.getActionListFor(object) + if action.test(ec)), key=lambda x: x['priority']) else: # for Action Providers written for CMF versions before 1.5