From 6194939d4a51ecf6871b2c272bf24fa0682b5d32 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Mon, 28 Apr 2014 11:06:01 +0200
Subject: [PATCH] fixup! ZODB Components: Export only the last Workflow
 History.

---
 product/ERP5/Document/BusinessTemplate.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index be5b9aad8b..8577aa377f 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -538,9 +538,12 @@ class BaseTemplateItem(Implicit, Persistent):
     bta.importFiles(item=self)
 
   def _removeAllButLastWorkflowHistory(self, obj):
-    for workflow_id in obj.workflow_history.keys():
-      obj.workflow_history[workflow_id] = WorkflowHistoryList(
-        obj.workflow_history[workflow_id][-1])
+    workflow_history = getattr(obj, 'workflow_history', None)
+    if workflow_history is None:
+      return
+    for workflow_id in workflow_history.keys():
+      workflow_history[workflow_id] = WorkflowHistoryList(
+        [workflow_history[workflow_id][-1]])
 
   def removeProperties(self,
                        obj,
-- 
2.30.9