Commit 85c1f807 authored by Julien Muchembled's avatar Julien Muchembled

migrateToEmbeddedFile: migrate directly to portal type class + option to simulate

parent b3e4561c
...@@ -26,19 +26,19 @@ ...@@ -26,19 +26,19 @@
# #
############################################################################## ##############################################################################
def migrateToEmbeddedFile(self): import erp5
""" Migrate all embedded "File" and "Image" from Products.ERP5.Extensions.CheckPortalTypes import changeObjectClass
def migrateToEmbeddedFile(self, force=0):
"""Migrate all embedded "File" and "Image"
objects to an unified "Embedded File objects to an unified "Embedded File
""" """
from Products.ERP5.Extensions.CheckPortalTypes import changeObjectClass portal_type = self.getPortalType()
from Products.ERP5.Document.EmbeddedFile import EmbeddedFile if portal_type in ('File', 'Image') and self.getValidationState()=='embedded':
embedded_type = 'Embedded File'
if self.getPortalType() in ('File', 'Image',) and \ container = self.getParentValue()
self.getValidationState()=='embedded': id = self.id
changeObjectClass(self.getParentValue(), self.id, EmbeddedFile) if force == 1:
instance = getattr(self.getParentValue(), self.id) changeObjectClass(container, id, getattr(erp5.portal_type, embedded_type))
instance.portal_type = EmbeddedFile.portal_type container._getOb(id).portal_type = embedded_type
instance.reindexObject() return '%s: %s -> %s' % (self.getRelativeUrl(), portal_type, embedded_type),
self.log("Migrated %s" %self.getRelativeUrl())
return self.getRelativeUrl()
\ No newline at end of file
...@@ -55,9 +55,10 @@ ...@@ -55,9 +55,10 @@
objects to an unified "Embedded File".\n objects to an unified "Embedded File".\n
"""\n """\n
active_process = context.getPortalObject().portal_activities.newActiveProcess()\n active_process = context.getPortalObject().portal_activities.newActiveProcess()\n
context.ERP5Site_checkDataWithScript("Base_migrateToEmbeddedFile", \n context.ERP5Site_checkDataWithScript("Base_migrateToEmbeddedFile",\n
tag="migrate",\n tag="migrate",\n
active_process=active_process.getPath())\n active_process=active_process.getPath(),\n
method_kw=dict(force=1))\n
\n \n
print "Migration started with process id: %s" %active_process.getPath()\n print "Migration started with process id: %s" %active_process.getPath()\n
return printed\n return printed\n
......
985 986
\ No newline at end of file \ No newline at end of file
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