From 8254f9e6d655b8a70e20584712200f1b77252ae2 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Tue, 22 Feb 2011 04:58:29 +0000
Subject: [PATCH] postpone migration if there is pending activities, the
 migration will be tried again later. This fix errors when updatint business
 templates on existing instances

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43541 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/mixin/id_as_reference.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Type/mixin/id_as_reference.py b/product/ERP5Type/mixin/id_as_reference.py
index 4ec1475bb7..4c1b5975d0 100644
--- a/product/ERP5Type/mixin/id_as_reference.py
+++ b/product/ERP5Type/mixin/id_as_reference.py
@@ -29,6 +29,7 @@
 import transaction
 from AccessControl import ClassSecurityInfo
 from Products.ERP5Type import Permissions, PropertySheet
+from Products.CMFActivity.Errors import ActivityPendingError
 from zLOG import LOG, WARNING
 
 def IdAsReferenceMixin(suffix):
@@ -50,8 +51,14 @@ def IdAsReferenceMixin(suffix):
           LOG("IdAsReferenceMixin", WARNING, "Skipping migration of %r in %r"
               " property sheet, due to ID conflict" % (new_id, parent.getId()))
         else:
-          del self.default_reference
-          self.setId(new_id)
+          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,
                               'getReference')
-- 
2.30.9