From d9ab5bda18744cbf29a2bc0c2b8447bfe1896f00 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Tue, 15 Sep 2009 04:59:41 +0000
Subject: [PATCH] Not proved in a unit test, but when removing items, it is
 safer to remove them in the reversed order. In fact, the previous code raises
 an exception, when an upgrade of a business template removes a workflow and a
 workflow chain related to this workflow at a time.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29054 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessTemplate.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 2f9f2e31cc..39c8112bc0 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -5020,7 +5020,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
       # remove object from old business template
       if len(remove_object_dict):
         # XXX: this code assumes that there is an installed_bt
-        for item_name in installed_bt._item_name_list:
+        for item_name in reversed(installed_bt._item_name_list):
           item = getattr(installed_bt, item_name, None)
           if item is not None:
             item.remove(self, remove_object_dict=remove_object_dict, trashbin=trashbin)
-- 
2.30.9