From 66d756ce5970988817c536b4ca3e716e974ea718 Mon Sep 17 00:00:00 2001
From: Ayush Tiwari <ayush.tiwari@nexedi.com>
Date: Wed, 17 May 2017 12:08:47 +0000
Subject: [PATCH] bt5_config: Add Business Manager portal_type also while
 checking for dependencies

---
 product/ERP5/Document/BusinessTemplate.py | 7 ++++++-
 product/ERP5/Tool/TemplateTool.py         | 8 +++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 21b5f61f7a..08f03974a7 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -2509,8 +2509,13 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
     force = kw.get('force')
     installed_bt = kw.get('installed_bt')
     if installed_bt is not None:
-      previous_portal_type_workflow_chain_list = list(installed_bt\
+      try:
+        previous_portal_type_workflow_chain_list = list(installed_bt\
           .getTemplatePortalTypeWorkflowChainList())
+      except Exception:
+        # This will happen in case the `installed_bt` is Business Manager, so
+        # we won't need to goto the further installation process
+        return
     else:
       previous_portal_type_workflow_chain_list = []
     # We now need to setup the list of workflows corresponding to
diff --git a/product/ERP5/Tool/TemplateTool.py b/product/ERP5/Tool/TemplateTool.py
index e2f846cb10..c1597a20f9 100644
--- a/product/ERP5/Tool/TemplateTool.py
+++ b/product/ERP5/Tool/TemplateTool.py
@@ -138,7 +138,13 @@ class TemplateTool (BaseTool):
       # potential danger because business templates may exchange catalog
       # methods, so the database could be broken temporarily.
       last_bt = last_time = None
-      for bt in self.objectValues(portal_type=['Business Template', 'Business Package']):
+      for bt in self.objectValues(portal_type=['Business Template',
+                                               'Business Package',
+                                               'Business Manager']):
+        if bt.getPortalType() == 'Business Manager':
+          if bt.getStatus() == 'installed':
+            return bt
+          return None
         if bt.getTitle() == title or title in bt.getProvisionList():
           state = bt.getInstallationState()
           if state == 'installed':
-- 
2.30.9