Commit 9f2212cf authored by wenjie.zheng's avatar wenjie.zheng

ERP5WorkflowMethod class created, correct all workflow5 indacation to ERP5Workflow.

parent 6dbab7ce
This diff is collapsed.
...@@ -418,13 +418,14 @@ class ERP5TypeInformation(XMLObject, ...@@ -418,13 +418,14 @@ class ERP5TypeInformation(XMLObject,
for workflow in workflow_tool.getWorkflowsFor(ob): for workflow in workflow_tool.getWorkflowsFor(ob):
workflow.notifyCreated(ob) workflow.notifyCreated(ob)
### Project WORKFLOW5 , WENJIE , 2014 ### # =========== Project ERP5Workflow , WENJIE , 2014 ================================
### workflow_list need to be defined somewhere.
for workflow5 in self.getTypeWorkflowList(): ### exp: ERP5Workflow in Person module won't work at this situation.
for ERP5Workflow in self.getTypeWorkflowList():
workflow_module = portal.getDefaultModule(portal_type="Workflow") workflow_module = portal.getDefaultModule(portal_type="Workflow")
workflow5 = workflow_module._getOb(workflow5) ERP5Workflow = workflow_module._getOb(ERP5Workflow)
workflow5.initializeDocument(ob) ERP5Workflow.initializeDocument(ob)
# =========== WF5 ==============================================================
if not temp_object: if not temp_object:
init_script = self.getTypeInitScriptId() init_script = self.getTypeInitScriptId()
......
...@@ -266,26 +266,22 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder): ...@@ -266,26 +266,22 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
else: else:
initializePortalTypeDynamicWorkflowMethods(cls, portal_workflow) initializePortalTypeDynamicWorkflowMethods(cls, portal_workflow)
# ================== Workflow5 Project, Wenjie, Dec 2014 ======================= # ================== ERP5Workflow Project, Wenjie, Dec 2014 =======================
### the ERP5Workflow list is defined in ERP5Type, only try to get erp5workflow
### when it's an erp5workflow related type.
portal_type = site.getDefaultModule(portal_type="portal_types") portal_type = site.getDefaultModule(portal_type="portal_types")
### try to get workflow_list from related types then initialize the class of types ### try to get workflow_list from related types then initialize the class of types
try: try:
pt = portal_type._getOb(cls.__name__) pt = portal_type._getOb(cls.__name__)
#raise NotImplemented (pt) #raise NotImplemented (pt)
if hasattr(pt, 'workflow_list'): if hasattr(pt, 'workflow_list'):
#if cls.__name__ == "Object Type": # Has to be redifined ### Get ERP5Workflow Module
portal_workflow5 = site.getDefaultModule(portal_type="Workflow") portal_ERP5Workflow = site.getDefaultModule(portal_type="Workflow")
#raise NotImplementedError (portal_workflow5) #<Workflow Module at workflow_module> if portal_ERP5Workflow is None:
#raise NotImplementedError (cls.__module__) #<class 'erp5.portal_type.Category Property'>
if portal_workflow5 is None:
LOG("ERP5Type.Dynamic", WARNING, LOG("ERP5Type.Dynamic", WARNING,
"no workflow5 methods for %s" "no ERP5Workflow methods for %s"
% cls.__name__) % cls.__name__)
else: else:
intializePortalTypeERP5WorkflowMethod(cls, portal_workflow5) ### Generate Workflow Method
intializePortalTypeERP5WorkflowMethod(cls, portal_ERP5Workflow)
except: except:
pass pass
# ================== WF5 ======================================================= # ================== WF5 =======================================================
......
...@@ -55,7 +55,7 @@ class Workflow(XMLObject): ...@@ -55,7 +55,7 @@ class Workflow(XMLObject):
isRADContent = 1 isRADContent = 1
### register the variable given by "base category value" ### register the variable given by "base category value"
#state_var = 'state' #state_var = 'state'
### In DCworkflow; state/transition can be registered inside workflow ### In DCworkflow; state/transition can be registered inside workflow
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -143,25 +143,25 @@ class Workflow(XMLObject): ...@@ -143,25 +143,25 @@ class Workflow(XMLObject):
transition=transition, transition=transition,
transition_url=transition_url, transition_url=transition_url,
state=state) state=state)
# ========== Workflow5 Project, Wenjie, Dec 2014 =============================== # ========== ERP5Workflow Project, Wenjie, Dec 2014 ===============================
def isWorkflow5MethodSupported(self, document, transition): def isERP5WorkflowMethodSupported(self, document, transition):
state = self._getWorkflow5StateOf(document) sdef = self._getERP5WorkflowStateOf(document)
if state is None: if sdef is None:
return 0 return 0
if transition in state.getDestinationValueList(): if transition in sdef.getDestinationValueList():
return 1 return 1
return 0 return 0
### get workflow state from base category value: ### get workflow state from base category value:
def _getWorkflow5StateOf(self, ob): def _getERP5WorkflowStateOf(self, ob):
bc_id = self.getStateBaseCategory() bc_id = self.getStateBaseCategory()
state_path = ob.getCategoryList() state_path = ob.getCategoryList()
state_path = state_path[0].lstrip("%s/"%bc_id) state_path = state_path[0].lstrip("%s/"%bc_id)
### ###
if state_path is not None: if state_path is not None:
state = self.restrictedTraverse(state_path) sdef = self.restrictedTraverse(state_path)
else: state = None else: sdef = None
return state return sdef
# =========== WF5 ============================================================== # =========== WF5 ==============================================================
########### ###########
## Graph ## ## Graph ##
......
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