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

ERP5Site.py: modify portal_workflow migration function, add workflow_module migration function.

parent ad705410
...@@ -1644,26 +1644,28 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -1644,26 +1644,28 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
""" manually called function to migrate dcworkflow to erp5workflow. """ manually called function to migrate dcworkflow to erp5workflow.
only for the specific case of workflow migration. only for the specific case of workflow migration.
""" """
if hasattr(self, 'portal_workflow_old'): tool = self.portal_workflow
tool = self.portal_workflow_old
object_id_list = tool.objectIds() object_id_list = tool.objectIds()
object_clipboard = tool.manage_copyObjects(object_id_list) object_clipboard = tool.manage_copyObjects(object_id_list)
new_tool = self.newContent(id='portal_workflow_new', portal_type='ERP5 Workflow Tool') new_tool = self.newContent(id='portal_workflow_new', portal_type='ERP5 Workflow Tool')
LOG(' ERP5Site.py', WARNING, ' create %s '%new_tool.id)
new_tool.manage_pasteObjects(object_clipboard) new_tool.manage_pasteObjects(object_clipboard)
new_tool._chains_by_type = tool._chains_by_type new_tool._chains_by_type = tool._chains_by_type
LOG(' ERP5Site.py', WARNING, ' copy objects to %s from %s.'%(new_tool.id, tool.id)) self.manage_delObjects(['portal_workflow'])
self.manage_renameObject(new_tool.id, 'portal_workflow')
if hasattr(self, 'portal_workflow_old'):
self.manage_delObjects(['portal_workflow'])
else:
self.manage_renameObject(tool.id, 'portal_workflow_old')
security.declareProtected(Permissions.ManagePortal,
'migrateWorkflowModuleToPortalWorkflow')
def migrateWorkflowModuleToPortalWorkflow(self):
""" manually called function to migrate dcworkflow to erp5workflow.
only for the specific case of workflow migration.
"""
tool = self.workflow_module
object_id_list = tool.objectIds()
new_tool = self.portal_workflow
object_clipboard = tool.manage_copyObjects(object_id_list)
new_tool = self.portal_workflow
new_tool.manage_pasteObjects(object_clipboard)
self.manage_renameObject(new_tool.id, 'portal_workflow')
Globals.InitializeClass(ERP5Site) Globals.InitializeClass(ERP5Site)
......
...@@ -50,6 +50,22 @@ def IdAsReferenceMixin(suffix): ...@@ -50,6 +50,22 @@ def IdAsReferenceMixin(suffix):
def getIdAsReferenceSuffix(): def getIdAsReferenceSuffix():
return suffix return suffix
def __migrate(self):
if self.id[suffix_index:] != suffix:
new_id = self.__dict__.get('default_reference') + suffix
parent = self.getParentValue()
if parent.has_key(new_id):
LOG("IdAsReferenceMixin", WARNING, "Skipping migration of %r in %r"
" property sheet, due to ID conflict" % (new_id, parent.getId()))
else:
try:
self.setId(new_id)
del self.default_reference
except ActivityPendingError:
LOG("IdAsReferenceMixin", WARNING, "Skipping migration of %r in %r"
" property sheet, due to pending activities" %
(new_id, parent.getId()))
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getReference') 'getReference')
def getReference(self, *args): def getReference(self, *args):
......
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