# HG changeset patch
# User Inigo Sanchez <inigo.sanchez@openbravo.com>
# Date 1432736820 -7200
#      Wed May 27 16:27:00 2015 +0200
# Node ID c65bec2e3c9876168af47e3749872e35965d2025
# Parent  e58f5e3d1259e6a91ea79e4d89c33327b22193e4
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").

diff -r e58f5e3d1259 -r c65bec2e3c98 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	Wed May 20 14:06:47 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();
