Fixes bug 19769: You cannot select a dataset through Enterprise module management with client/organization access level
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Wed, 15 Feb 2012 20:31:23 +0100
changeset 15516 f0b97d072dbb
parent 15515 6bacc910b064
child 15517 4561e31e98e3
Fixes bug 19769: You cannot select a dataset through Enterprise module management with client/organization access level
src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData.java
src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData_data.xsql
src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData.java	Thu Feb 16 10:04:53 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData.java	Wed Feb 15 20:31:23 2012 +0100
@@ -55,7 +55,12 @@
       throws ServletException, IOException {
     VariablesSecureApp vars = new VariablesSecureApp(request);
     if (vars.commandIn("DEFAULT")) {
-      String strOrganization = vars.getStringParameter("inpOrganization", "0");
+      // If no organization is retrieved then first organization displayed in the mandatory combo is
+      // takes as default
+      UpdateReferenceDataData[] data = UpdateReferenceDataData.selectOrganization(this,
+          vars.getRole(), vars.getUserOrg());
+      String strOrganization = vars.getStringParameter("inpOrganization",
+          data.length > 0 ? data[0].id : "");
       printPage(response, vars, strOrganization);
     } else if (vars.commandIn("OK")) {
       StringBuffer m_info = new StringBuffer();
--- a/src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData_data.xsql	Thu Feb 16 10:04:53 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData_data.xsql	Wed Feb 15 20:31:23 2012 +0100
@@ -61,12 +61,13 @@
       FROM AD_MODULE, AD_DATASET
       WHERE AD_MODULE.AD_MODULE_ID = AD_DATASET.AD_MODULE_ID      
       AND AD_MODULE.AD_MODULE_ID IN ('1')
-      AND (AD_DATASET.ACCESSLEVEL IN ('3','1') OR (? = '0' AND AD_DATASET.ACCESSLEVEL IN ('3','6')))
+      AND ((? <> '0' AND AD_DATASET.ACCESSLEVEL IN ('3','1')) OR (? = '0' AND AD_DATASET.ACCESSLEVEL IN ('3','6')))
       ORDER BY AD_MODULE.AD_MODULE_ID, AD_DATASET.SEQNO, AD_DATASET.AD_DATASET_ID
       ]]>
     </Sql>
     <Parameter name="modules" optional="true" type="replace" after="AD_MODULE_ID IN " text="('1')"/>
     <Parameter name="organization"/>
+    <Parameter name="organization"/>
   </SqlMethod>
   <SqlMethod name="selectRegister" type="preparedStatement" return="string">
     <SqlMethodComment></SqlMethodComment>
--- a/src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree_data.xsql	Thu Feb 16 10:04:53 2012 +0100
+++ b/src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree_data.xsql	Wed Feb 15 20:31:23 2012 +0100
@@ -78,7 +78,7 @@
                     FROM AD_Module_Dependency
                    WHERE AD_Module_ID = M.AD_Module_ID
                      AND IsIncluded = 'Y')                as display, m.Status, m.help, m.author, m.url,
-                     CASE WHEN COALESCE(AD_ORGMODULE.VERSION,M.VERSION) <> M.VERSION THEN 'Y' ELSE '' END AS Update_Available,
+                     CASE WHEN AD_ORGMODULE.CHECKSUM NOT LIKE '%'|| AD_DATASET.CHECKSUM  ||'%' 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
@@ -97,8 +97,14 @@
                             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  ||'%')
+            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
           ]]>
@@ -108,6 +114,10 @@
       <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>