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