Commit c866c993 authored by wenjie.zheng's avatar wenjie.zheng Committed by Sebastien Robin

WorkflowState.py: modify workflow getter since workflow_module has been merged...

WorkflowState.py: modify workflow getter since workflow_module has been merged with portal_workflow.
parent 53646336
...@@ -55,13 +55,13 @@ class Getter(BaseGetter): ...@@ -55,13 +55,13 @@ class Getter(BaseGetter):
self._key = key self._key = key
def __call__(self, instance): def __call__(self, instance):
try: portal_workflow = instance.getPortalObject().portal_workflow
erp5Workflow_module = instance.getPortalObject()._getOb("workflow_module", None) wf = portal_workflow.getWorkflowById(self._key)
wf = erp5Workflow_module._getOb(self._key)### _getObjectByRef if wf.getPortalType() in ['Workflow', 'Interaction Workflow']:
except: # remove id suffix for workflow and interaction workflow
portal_workflow = instance.getPortalObject().portal_workflow return '_'.join(wf._getWorkflowStateOf(instance, id_only=1).split('_')[0:-1])
wf = portal_workflow.getWorkflowById(self._key) else:
return wf._getWorkflowStateOf(instance, id_only=1) return wf._getWorkflowStateOf(instance, id_only=1)
psyco.bind(__call__) psyco.bind(__call__)
...@@ -84,12 +84,8 @@ class TitleGetter(BaseGetter): ...@@ -84,12 +84,8 @@ class TitleGetter(BaseGetter):
self._key = key self._key = key
def __call__(self, instance): def __call__(self, instance):
try: portal_workflow = instance.getPortalObject().portal_workflow
erp5Workflow_module = instance.getPortalObject()._getOb("workflow_module", None) wf = portal_workflow.getWorkflowById(self._key)
wf = erp5Workflow_module._getOb(self._key)### _getObjectByRef
except:
portal_workflow = instance.getPortalObject().portal_workflow
wf = portal_workflow.getWorkflowById(self._key)
return wf._getWorkflowStateOf(instance).getTitle() return wf._getWorkflowStateOf(instance).getTitle()
psyco.bind(__call__) psyco.bind(__call__)
...@@ -99,13 +95,12 @@ class TranslatedGetter(Getter): ...@@ -99,13 +95,12 @@ class TranslatedGetter(Getter):
""" """
def __call__(self, instance): def __call__(self, instance):
try: portal = instance.getPortalObject()
erp5Workflow_module = instance.getPortalObject()._getOb("workflow_module", None) wf = portal.portal_workflow.getWorkflowById(self._key)
wf = erp5Workflow_module._getOb(self._key)### _getObjectByRef if wf.getPortalType() in ['Workflow','Interaction Workflow']:
except: state_id = '_'.join(wf._getWorkflowStateOf(instance, id_only=1).split('_')[0:-1])
portal = instance.getPortalObject() else:
wf = portal.portal_workflow.getWorkflowById(self._key) state_id = wf._getWorkflowStateOf(instance, id_only=1)
state_id = wf._getWorkflowStateOf(instance, id_only=1)
warn('Translated workflow state getters, such as %s are deprecated' % warn('Translated workflow state getters, such as %s are deprecated' %
self._id, DeprecationWarning) self._id, DeprecationWarning)
return portal.Localizer.erp5_ui.gettext(state_id).encode('utf8') return portal.Localizer.erp5_ui.gettext(state_id).encode('utf8')
...@@ -121,11 +116,7 @@ class TranslatedTitleGetter(TitleGetter): ...@@ -121,11 +116,7 @@ class TranslatedTitleGetter(TitleGetter):
portal = instance.getPortalObject() portal = instance.getPortalObject()
localizer = portal.Localizer localizer = portal.Localizer
wf_id = self._key wf_id = self._key
try: wf = portal.portal_workflow.getWorkflowById(wf_id)
erp5Workflow_module = instance.getPortalObject()._getOb("workflow_module", None)
wf = erp5Workflow_module._getOb(self._key) ### _getObjectByRef
except:
wf = portal.portal_workflow.getWorkflowById(wf_id)
selected_language = localizer.get_selected_language() selected_language = localizer.get_selected_language()
state_title = wf._getWorkflowStateOf(instance).title state_title = wf._getWorkflowStateOf(instance).title
......
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