Fixed issue 29602: window with table defined as view should be RO
authorInigo Sanchez <inigo.sanchez@openbravo.com>
Wed, 27 May 2015 16:27:00 +0200
changeset 26836 099550fa4baa
parent 26835 a6e31121bf79
child 26837 eef37b346fe4
Fixed issue 29602: window with table defined as view should be RO

The problem was that if you had a window that was assigned with a
table defined as view you could edited.

Now, it is taking into account this condition by checking windows
(Type window "M" and "T").
modules/org.openbravo.client.application/src/org/openbravo/client/application/WindowSettingsActionHandler.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/WindowSettingsActionHandler.java	Fri May 29 13:58:50 2015 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/WindowSettingsActionHandler.java	Wed May 27 16:27:00 2015 +0200
@@ -83,6 +83,16 @@
         final boolean readOnlyAccess = org.openbravo.erpCommon.utility.WindowAccessData
             .hasReadOnlyAccess(dalConnectionProvider, roleId, tab.getId());
         String uiPattern = readOnlyAccess ? "RO" : tab.getUIPattern();
+        // window should be read only when is assigned with a table defined as a view
+        if (tab.getTable().getWindow() != null) {
+          String windowType = tab.getTable().getWindow().getWindowType();
+          if (!"RO".equals(uiPattern) && tab.getTable().isView()
+              && ("T".equals(windowType) || "M".equals(windowType))) {
+            log4j.warn("Tab \"" + tab.getName()
+                + "\" is set to read only because is assigned with a table defined as a view.");
+            uiPattern = "RO";
+          }
+        }
         jsonUIPattern.put(tab.getId(), uiPattern);
       }
       final JSONObject json = new JSONObject();