Fixes issue 35419:Cannot remove an orphan line in Return to/from vendor/customer
authorMiguel <martencobasmiguel@gmail.com>
Thu, 02 Mar 2017 14:17:25 -0500
changeset 31449 dc07ac3f254c
parent 31448 c978e345ba22
child 31450 a44dc7a7fead
child 32034 a87f1ae21860
Fixes issue 35419:Cannot remove an orphan line in Return to/from vendor/customer

Was not able to remove an orphan line from a return to vendor or a return from
customer document because an incorrect casting to boolean.

When is validating tha Last record is selected inside the Orphan grid lines, the
lastRecord.get("obSelected") object gets as String instead of a Boolean object,
in other case it gets as Boolean.

Now, conditions are rightly validated depending of the class of the object.
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java	Thu Mar 02 09:22:31 2017 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java	Thu Mar 02 14:17:25 2017 -0500
@@ -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-2016 Openbravo SLU 
+ * All portions are Copyright (C) 2010-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -186,9 +186,16 @@
     if (data.size() == 0) {
       return false;
     }
+    Boolean isLastRecordSelected = Boolean.FALSE;
     Map<String, Object> lastRecord = data.get(data.size() - 1);
     Object obSelected = lastRecord.get("obSelected");
-    Boolean isLastRecordSelected = obSelected == null ? Boolean.FALSE : (Boolean) obSelected;
+    if (obSelected != null) {
+      if (obSelected.getClass().equals(Boolean.class)) {
+        isLastRecordSelected = (Boolean) obSelected;
+      } else if (obSelected.getClass().equals(String.class)) {
+        isLastRecordSelected = ((String) obSelected).equalsIgnoreCase("Y");
+      }
+    }
     return isLastRecordSelected.booleanValue();
   }