diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 926e09562f77119a11b0dd72cf68cce299c4130a..1027ac1a6355c06b703ea5449fee5d29e06bcca6 100644 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -33,6 +33,7 @@ import ExtensionClass from Globals import InitializeClass, DTMLFile, PersistentMapping from AccessControl import ClassSecurityInfo from AccessControl.Permission import pname, Permission +from AccessControl.PermissionRole import rolesForPermissionOn from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain import OFS.History @@ -357,11 +358,14 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): method_id) else: # Wrap method into WorkflowMethod is needed - if getattr(klass,method_id,None) is not None: + if getattr(klass, method_id, None) is not None: method = getattr(klass, method_id) if callable(method): if not isinstance(method, WorkflowMethod): method = WorkflowMethod(method, method_id) + # We must set the method on the klass + # because klass has priority in lookup over + # _ac_dynamic setattr(klass, method_id, method) else: method = getattr(prop_holder, method_id) @@ -1419,6 +1423,18 @@ class Base( CopyContainer, return tuple(permission_list) + security.declareProtected( Permissions.AccessContentsInformation, 'getViewPermissionOwner' ) + def getViewPermissionOwner(self): + """ + Returns the user ID of the owner if Owner role + has View permission. Returns None else. + """ + path, user_id = self.getOwnerTuple() + if 'Owner' in rolesForPermissionOn(Permissions.View, self): + path, user_id = self.getOwnerTuple() + return user_id + return None + # Private accessors for the implementation of relations based on # categories security.declareProtected( Permissions.ModifyPortalContent, '_setValue' )