Change the way content is added to the folder, so our chosen id is kept

This commit is contained in:
Frédéric Péters 2011-07-27 17:12:25 +02:00
parent 52d2c54389
commit f87dc75c98
1 changed files with 5 additions and 4 deletions

View File

@ -36,11 +36,12 @@ class Migrate(BrowserView):
# first step is to create a "courrier entrant" object
typename = 'courrier_entrant'
factory = DexterityFactory(portal_type=typename)
if hasattr(self.context, doc.get('id')):
ob = getattr(self.context, doc.get('id'))
else:
if not hasattr(self.context, doc.get('id')):
ob = factory(id=doc.get('id'), title=doc.get('title'))
addContentToContainer(self.context, ob)
self.context._setObject(ob.id, ob)
ob = getattr(self.context, doc.get('id'))
ob.date_reception = datetime.datetime.strptime(doc.get('deliverydate'), '%Y-%m-%d').date()
ob.numero_courrier = doc.get('mailnumber')