Fixed bug 21294, Fixed bug 21316: Enterprise Module Management
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Mon, 06 Aug 2012 14:38:55 +0200
changeset 9883 cab2322adf42
parent 9874 ae4783f13a71
child 9884 d96d77790ca9
Fixed bug 21294, Fixed bug 21316: Enterprise Module Management

+ Client/Org modules are now properly displayed
+ An already applied dataset is not shown anymore for ancestor/child orgs
+ Checksum is now taken into account in case of updates. We also use the versions for
those scenarios where the dataset has been created without checksum (old 2.50 modules)
+ ISACTIVE column is taken into account

+ The LEFT JOIN is now filtering by the selected organization. The client is also
included into the join clause to avoid swapping the client and org parameters into
the generated sqlc method.
src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree_data.xsql
--- a/src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree_data.xsql	Tue Jul 17 06:02:47 2012 +0000
+++ b/src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree_data.xsql	Mon Aug 06 14:38:55 2012 +0200
@@ -12,7 +12,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2008-2009 Openbravo SLU
+ * All portions are Copyright (C) 2008-2012 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -56,7 +56,8 @@
 			AND ((EXISTS (SELECT 1 FROM ad_dataset
 							WHERE M.ad_module_id = AD_DATASET.ad_module_id
 							AND AD_DATASET.ACCESSLEVEL IN ('3','1')
-							AND AD_DATASET.EXPORTALLOWED = 'Y')
+							AND AD_DATASET.EXPORTALLOWED = 'Y'
+							AND ISACTIVE = 'Y')
 						AND M.HASREFERENCEDATA = 'Y')
 						OR M.haschartofaccounts = 'Y')
 			AND NOT EXISTS (SELECT 1 FROM AD_CLIENTMODULE CM
@@ -81,9 +82,10 @@
                      CASE WHEN COALESCE(AD_ORGMODULE.VERSION,M.VERSION) <> M.VERSION THEN 'Y' ELSE '' END AS Update_Available,
                      m.seqno
            FROM AD_Module M left join AD_DATASET on M.ad_module_id = AD_DATASET.ad_module_id
-			    LEFT JOIN AD_ORGMODULE ON M.AD_MODULE_ID = AD_ORGMODULE.AD_MODULE_ID
+			    LEFT JOIN AD_ORGMODULE ON (M.AD_MODULE_ID = AD_ORGMODULE.AD_MODULE_ID AND AD_ORGMODULE.AD_Client_ID = ? AND AD_ORGMODULE.AD_ORG_ID = ? )
           WHERE M.TYPE = 'M'
             AND M.ISACTIVE = 'Y'
+            AND AD_DATASET.ISACTIVE = 'Y'
             AND 1=1
             AND M.HASREFERENCEDATA = 'Y'
             AND EXPORTALLOWED = 'Y'
@@ -97,17 +99,31 @@
                             AND OM.AD_CLIENT_ID = ?
                             AND (AD_IsOrgIncluded(?, OM.AD_Org_ID, OM.AD_Client_ID)<>-1
                             OR AD_IsOrgIncluded(OM.AD_Org_ID, ?, OM.AD_Client_ID)<>-1)
-                            AND OM.VERSION = M.VERSION)
-            AND (((? <> '0') AND AD_DATASET.ACCESSLEVEL IN ('1'))
+                            AND (OM.CHECKSUM LIKE '%'|| AD_DATASET.CHECKSUM  ||'%'
+                             /* it hides the dataset in case both checksum are null (it may happen in datasets created without checksum column) */
+                            OR COALESCE(OM.VERSION,M.VERSION) = M.VERSION))
+            AND NOT EXISTS (SELECT 1 FROM AD_ORGMODULE OM
+                            WHERE OM.ad_module_id = M.ad_module_id
+                            AND OM.AD_CLIENT_ID = ?
+                            AND (AD_IsOrgIncluded(OM.AD_Org_ID, ?, OM.AD_Client_ID)<>-1
+                            OR AD_IsOrgIncluded(?, OM.AD_Org_ID, OM.AD_Client_ID)<>-1)
+                            AND OM.ad_org_id <> ?)                            
+            AND (((? <> '0') AND AD_DATASET.ACCESSLEVEL IN ('1', '3'))
                 OR ((? = '0') AND AD_DATASET.ACCESSLEVEL IN ('3', '6')))) A
           ORDER BY A.SeqNo
           ]]>
       </Sql>
       <Parameter name="lang"/>
       <Parameter name="client"/>
+      <Parameter name="org"/>
+      <Parameter name="client"/>
       <Parameter name="client"/>
       <Parameter name="org"/>
       <Parameter name="org"/>
+      <Parameter name="client"/>
+      <Parameter name="org"/>
+      <Parameter name="org"/>      
+      <Parameter name="org"/>      
       <Parameter name="org"/>
       <Parameter name="org"/>
    </SqlMethod>
@@ -130,7 +146,8 @@
                             AND IsIncluded = 'Y')
             AND EXISTS (SELECT 1 FROM AD_DATASET
                         WHERE AD_DATASET.AD_MODULE_ID = M.AD_MODULE_ID
-                        AND EXPORTALLOWED = 'Y')
+                        AND EXPORTALLOWED = 'Y'
+                        AND ISACTIVE = 'Y')
              AND ISACTIVE = 'Y'
      </Sql>
      <Parameter name="lang"/>