From bf6c2ad22704ae8455386f584e6fba1b7cdb4bd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Thu, 9 Feb 2012 17:25:55 +0100
Subject: [PATCH] Support both cases.

Some software instances has no open sale order line related.
---
 .../SoftwareInstance_getRootHostingSubscriptionUid.xml     | 7 +++++++
 master/bt5/vifib_base/bt/revision                          | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/master/bt5/vifib_base/SkinTemplateItem/portal_skins/vifib_base/SoftwareInstance_getRootHostingSubscriptionUid.xml b/master/bt5/vifib_base/SkinTemplateItem/portal_skins/vifib_base/SoftwareInstance_getRootHostingSubscriptionUid.xml
index b87a0d30b..6606a0bed 100644
--- a/master/bt5/vifib_base/SkinTemplateItem/portal_skins/vifib_base/SoftwareInstance_getRootHostingSubscriptionUid.xml
+++ b/master/bt5/vifib_base/SkinTemplateItem/portal_skins/vifib_base/SoftwareInstance_getRootHostingSubscriptionUid.xml
@@ -71,6 +71,13 @@ if root_hosting_subscription is None:\n
   order_line = root_software_instance.getAggregateRelatedValue(portal_type=\'Sale Order Line\')\n
   if order_line is not None:\n
     root_hosting_subscription = order_line.getAggregateValue(portal_type=\'Hosting Subscription\')\n
+  else:\n
+    try:\n
+      instance_setup_line = root_software_instance.Item_getInstancePackingListLine()\n
+    except ValueError:\n
+      pass\n
+    else:\n
+      root_hosting_subscription = instance_setup_line.getAggregateValue(portal_type=\'Hosting Subscription\')\n
   if root_hosting_subscription is None:\n
     raise ConsistencyError(("Software instance %s has no hosting "\n
                           "subscription as root.") % context.getReference())\n
diff --git a/master/bt5/vifib_base/bt/revision b/master/bt5/vifib_base/bt/revision
index 96baa1348..6d540e9f2 100644
--- a/master/bt5/vifib_base/bt/revision
+++ b/master/bt5/vifib_base/bt/revision
@@ -1 +1 @@
-381
\ No newline at end of file
+382
\ No newline at end of file
-- 
2.30.9