# HG changeset patch
# User Naroa Iriarte <naroa.iriarte@openbravo.com>
# Date 1467283985 -7200
#      Thu Jun 30 12:53:05 2016 +0200
# Node ID a9666858ca12665bf2f4ba48523a428ab4862dd0
# Parent  901f72e322e476f69a7abedf68154bd850dda82d
Fixed issue 33216: The onChange Event didn't work properly

The problem was that the client side callouts were not working properly the second time a record of a pick and edit window was modified in grid view.
The expected behavior is that a value put in one concrete field is copied to another when the first one looses the focus.
The problem was when the productCharacteristics item was present.
In the ob-pick-and-execute-view.js there was a condition wich was setting the
property "readOnlyEditorType" to "OBTextItem" for the fields including the productCharacteristics one.
This was causing the problem afterwards when the check "his.getEditorType(editField, values) != this._editRowForm.getEditorType(liveItem)"
was done in the ListGrid.js because the left part was retrieving "OBTextItem" instead of "OBCharacteristicsGridItem".
This has been fixed by creating this property for the characteristics items. To do so, CharacteristicsGridItem.java has now
a new method which retrieves the value "OBCharacteristicsGridItem". In the ftl now, the property "readOnlyEditorType" is set.
Now the condition of the ob-pick-and-execute-view.js has changed and it checks if there exists the "readOnlyEditorType" property
for the current field. If it exists, it will not do anithing and if not, the property will be set as "OBTextItem" as it was
doing before. Now, the characteristic items will have that property set as "OBCharacteristicsGridItem" and it will work properly.

diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
@@ -2926,6 +2926,7 @@
       }
 
       type = isc.SimpleType.getType(fld.type);
+      fld.readOnlyEditorType = type.readOnlyEditorType;
       if (type.editorType && !fld.editorType) {
         fld.editorType = type.editorType;
       }
diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-view.js
@@ -133,7 +133,9 @@
     for (i = 0; i < len; i++) {
       if (result[i].editorProperties && result[i].editorProperties.disabled) {
         result[i].canEdit = false;
-        result[i].readOnlyEditorType = 'OBTextItem';
+        if (!result[i].readOnlyEditorType) {
+          result[i].readOnlyEditorType = 'OBTextItem';
+        }
       } else {
         result[i].validateOnExit = true;
       }
diff --git a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/CharacteristicsUIDefinition.java b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/CharacteristicsUIDefinition.java
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/CharacteristicsUIDefinition.java
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/CharacteristicsUIDefinition.java
@@ -11,7 +11,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) 2013 Openbravo SLU
+ * All portions are Copyright (C) 2013-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -61,6 +61,11 @@
   }
 
   @Override
+  public String getReadOnlyEditorType() {
+    return "OBCharacteristicsGridItem";
+  }
+
+  @Override
   public String getFieldProperties(Field field, boolean getValueFromSession) {
     String result = super.getFieldProperties(field, getValueFromSession);
     OBContext.setAdminMode(true);
diff --git a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
@@ -102,6 +102,13 @@
   }
 
   /**
+   * @return the read only editor type. As default will return "".
+   */
+  public String getReadOnlyEditorType() {
+    return "";
+  }
+
+  /**
    * @return the form item type used for filtering in grids. As a default will return
    *         {@link #getFormEditorType()}
    */
diff --git a/modules/org.openbravo.userinterface.smartclient/src/org/openbravo/userinterface/smartclient/templates/smartclient_types_js.ftl b/modules/org.openbravo.userinterface.smartclient/src/org/openbravo/userinterface/smartclient/templates/smartclient_types_js.ftl
--- a/modules/org.openbravo.userinterface.smartclient/src/org/openbravo/userinterface/smartclient/templates/smartclient_types_js.ftl
+++ b/modules/org.openbravo.userinterface.smartclient/src/org/openbravo/userinterface/smartclient/templates/smartclient_types_js.ftl
@@ -11,7 +11,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) 2010-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2010-2016 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
     editorType: '${uiDefinition.formEditorType?js_string}',
     gridEditorType: '${uiDefinition.gridEditorType?js_string}',
     filterEditorType: '${uiDefinition.filterEditorType?js_string}',
+    readOnlyEditorType: '${uiDefinition.readOnlyEditorType?js_string}',
     </#if>
     ${uiDefinition.typeProperties}
     referenceName: '${uiDefinition.reference.name?js_string}'
