Fixed issue with ClientInformation and OrganizationInformation in OB3
authorAntonio Moreno <antonio.moreno@openbravo.com>
Tue, 26 Jul 2011 12:40:29 +0200
changeset 13268 5b9f270d0bff
parent 13267 bc4bd502bc4d
child 13269 8bfbd41b6ea6
Fixed issue with ClientInformation and OrganizationInformation in OB3
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Tue Jul 26 12:30:41 2011 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Tue Jul 26 12:40:29 2011 +0200
@@ -381,24 +381,25 @@
       }
 
       if (mode.equals("EDIT") && row != null) {
-        if (((ClientEnabled) row).getClient() != null
-            || ((OrganizationEnabled) row).getOrganization() != null) {
+        if ((row instanceof ClientEnabled && ((ClientEnabled) row).getClient() != null)) {
           final String rowClientId = ((ClientEnabled) row).getClient().getId();
           final String currentClientId = OBContext.getOBContext().getCurrentClient().getId();
           if (!rowClientId.equals(currentClientId)) {
             finalObject.put("_readOnly", true);
-          } else {
-            boolean writable = false;
-            final String objectOrgId = ((OrganizationEnabled) row).getOrganization().getId();
-            for (String orgId : OBContext.getOBContext().getWritableOrganizations()) {
-              if (orgId.equals(objectOrgId)) {
-                writable = true;
-                break;
-              }
+          }
+        }
+        if (row instanceof OrganizationEnabled
+            && ((OrganizationEnabled) row).getOrganization() != null) {
+          boolean writable = false;
+          final String objectOrgId = ((OrganizationEnabled) row).getOrganization().getId();
+          for (String orgId : OBContext.getOBContext().getWritableOrganizations()) {
+            if (orgId.equals(objectOrgId)) {
+              writable = true;
+              break;
             }
-            if (!writable) {
-              finalObject.put("_readOnly", true);
-            }
+          }
+          if (!writable) {
+            finalObject.put("_readOnly", true);
           }
         }
       }