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