diff --git a/product/ERP5/bootstrap/erp5_type/SkinTemplateItem/portal_skins/erp5_type/ERP5Site_createModule.xml b/product/ERP5/bootstrap/erp5_type/SkinTemplateItem/portal_skins/erp5_type/ERP5Site_createModule.xml index 8b5732ac18634c832ac9c65eea6beadf76ddac14..fe3d069c184afce06ac0066d08010d9fad3875bd 100644 --- a/product/ERP5/bootstrap/erp5_type/SkinTemplateItem/portal_skins/erp5_type/ERP5Site_createModule.xml +++ b/product/ERP5/bootstrap/erp5_type/SkinTemplateItem/portal_skins/erp5_type/ERP5Site_createModule.xml @@ -79,7 +79,7 @@ module_list_form_id = (\'%s_view%sList\' % (module_portal_type,\n module_portal_type_value.newContent(portal_type=\'Action Information\',\n reference="view",\n title="View",\n - action_expression="string:${object_url}/%s" % module_list_form_id,\n + action="string:${object_url}/%s" % module_list_form_id,\n action_type="object_list")\n \n # Create the skin folder if does not exist yet\n @@ -186,7 +186,7 @@ portal.portal_workflow.setChainForPortalTypes([object_portal_type_id],\n object_portal_type_value.newContent(portal_type=\'Action Information\',\n reference="view",\n title="View",\n - action_expression="string:${object_url}/%s" % form_view_id,\n + action="string:${object_url}/%s" % form_view_id,\n action_type="object_view")\n \n # Finally add the module to the site\n diff --git a/product/ERP5Type/Core/ActionInformation.py b/product/ERP5Type/Core/ActionInformation.py index 110159d2bf681c44026906cf8382612a8cff2438..d20cf5ecc151697fc62357e9f1249929cd227dd9 100644 --- a/product/ERP5Type/Core/ActionInformation.py +++ b/product/ERP5Type/Core/ActionInformation.py @@ -84,17 +84,17 @@ class ActionInformation(XMLObject): return condition is None or condition(ec) return False - security.declarePublic('getVisibility') - def getVisibility(self): - """Return whether the action should be visible in the CMF UI""" - return self.isVisible() + security.declarePrivate('getActionUrl') + def getActionUrl(self, ec): + action = self.getAction() + return action is not None and action(ec) or '' - def _setActionExpression(self, value): + def _setAction(self, value): """Overridden setter for 'action' to accept strings and clean null values """ if isinstance(value, basestring): value = value and Expression(value) or None - self._baseSetActionExpression(value) + self._baseSetAction(value) def _setCondition(self, value): """Overridden setter for 'condition' to accept string and clean null values """ @@ -108,6 +108,11 @@ class ActionInformation(XMLObject): value = value and Expression(value) or None self._baseSetIcon(value) + def getAction(self): + """Overridden getter for 'action' to clean null values""" + if getattr(aq_base(self), 'action', None) == '': + del self.action + return self._baseGetAction() def getCondition(self): """Overridden getter for 'condition' to clean null values""" if getattr(aq_base(self), 'condition', None) == '': @@ -122,7 +127,7 @@ class ActionInformation(XMLObject): security.declareProtected(AccessContentsInformation, 'getActionText') def getActionText(self): """Return the text of the action expression""" - return getattr(self.getActionExpression(), 'text', None) + return getattr(self.getAction(), 'text', None) security.declareProtected(AccessContentsInformation, 'getConditionText') def getConditionText(self): """Return the text of the condition expression""" @@ -141,7 +146,3 @@ class ActionInformation(XMLObject): self.getActionText(), self.getConditionText()] return ' '.join(filter(None, search_source_list)) - - security.declarePrivate('getActionUrl') - def getActionUrl(self, ec): - return self.getActionExpression()(ec) diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 75fb8ec43c73e9c203fc1ec761ca95716b351894..188c26ba5d9a4b5faa954488227d0531561fe9e5 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -574,6 +574,7 @@ class ERP5TypeInformation(XMLObject, v = v.__class__(v.text) setattr(action, {'id': 'reference', 'priority': 'float_index', + 'permissions': 'action_permission', }.get(k, k), v) action.uid = None action = self[self._setObject(action.id, action, set_owner=0)] @@ -585,13 +586,12 @@ class ERP5TypeInformation(XMLObject, from Products.CMFCore.ActionInformation import ActionInformation old_action = ActionInformation(action.reference, category=action.getActionType(), - # We don't have the same default values for the following properties: priority=action.getFloatIndex(), permissions=tuple(action.getActionPermissionList())) for k, v in action.__dict__.iteritems(): if k in ('action', 'condition', 'icon'): v = v.__class__(v.text) - elif k in ('id', 'float_index', 'permissions', 'reference'): + elif k in ('id', 'float_index', 'action_permission', 'reference'): continue setattr(old_action, k, v) return old_action diff --git a/product/ERP5Type/PropertySheet/ActionInformation.py b/product/ERP5Type/PropertySheet/ActionInformation.py index 433bea28279893a64cd32f3ae96d5ca3b571e411..c6c3643e1c439a74785201521e54a3078f375836 100644 --- a/product/ERP5Type/PropertySheet/ActionInformation.py +++ b/product/ERP5Type/PropertySheet/ActionInformation.py @@ -44,7 +44,6 @@ class ActionInformation: 'mode': 'w', }, { 'id': 'action_permission', - 'storage_id': 'permissions', # CMF Compatibility 'type': 'lines', 'description': 'The permissions required to use the action', 'mode': 'w', @@ -62,8 +61,7 @@ class ActionInformation: 'mode': 'w', 'default': True, }, - { 'id': 'action_expression', # CMF Compatibility - 'storage_id': 'action', + { 'id': 'action', 'type': 'object', 'description': 'TALES Expression to define the URL of the action', 'mode': 'w',