From 89d8a0e32b903e87bcf49b1d4a7c0a49fb6e48dc Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Fri, 30 Oct 2009 15:27:31 +0000
Subject: [PATCH] modify r30158 change because several tools still use CMF
 actions: > now we need to find action information object by matching
 'reference' instead of 'id'. with this fix, action can be successfully
 removed. and if action if missing, we output log just same as portal type
 itself is missing.

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

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index a97c07cc4a..a869b8ae15 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -2551,10 +2551,14 @@ class ActionTemplateItem(ObjectTemplateItem):
     for id in keys:
       if  '|' in id:
         relative_url, value = id.split(' | ')
-        key = 'reference'
+        obj = p.unrestrictedTraverse(relative_url, None)
+        # Several tools still use CMF actions
+        if obj is not None:
+          is_new_action = obj.getParentId() == 'portal_types'
+          key = is_new_action and 'reference' or 'id'
       else:
         relative_url, key, value = self._splitPath(id)
-      obj = p.unrestrictedTraverse(relative_url, None)
+        obj = p.unrestrictedTraverse(relative_url, None)
       if obj is not None:
         action_list = obj.listActions()
         for index in range(len(action_list)):
-- 
2.30.9