Fixes issue 32233: Payment In and Payment Out lines are not exported to CSV.
authorInigo Sanchez <inigo.sanchez@openbravo.com>
Mon, 29 Feb 2016 23:49:20 +0100
changeset 28687 8c53c9e9c26f
parent 28686 6f297f8de5d6
child 28688 817351be2c23
child 29332 4a96cf07e60b
Fixes issue 32233: Payment In and Payment Out lines are not exported to CSV.

The problem was that export to CSV does not work properly in some subtabs without
link to parent column (e.g.Lines subtab of Payment In/Out). Before, It was used
"tabId" to obtaing data for export to CSV and the value of the "tabId" was sent
in a variable called "tab". The Criteria that is run when it is displayed the tab
uses a property named "tabId" instead of "tab".

The solution for this case (and other related cases) is to adapt the code that
exports to CSV to use the same Criteria run when displaying the tab. Now export
to CSV uses tabId property. Besides it has been refactored some piece of code
related with export data in DataSourceServlet to use "tabId" instead of "tab".
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Thu Feb 18 13:23:15 2016 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Mon Feb 29 23:49:20 2016 +0100
@@ -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-2015 Openbravo SLU
+ * All portions are Copyright (C) 2010-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -1071,7 +1071,7 @@
       exportAs: expProp.exportAs || 'csv',
       viewState: expProp.viewState,
       _extraProperties: expProp._extraProperties,
-      tab: expProp.tab,
+      tabId: expProp.tab,
       exportToFile: true,
       _textMatchStyle: 'substring',
       _UTCOffsetMiliseconds: OB.Utilities.Date.getUTCOffsetInMiliseconds()
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java	Thu Feb 18 13:23:15 2016 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java	Mon Feb 29 23:49:20 2016 +0100
@@ -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) 2009-2015 Openbravo SLU
+ * All portions are Copyright (C) 2009-2016 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -226,9 +226,10 @@
           try {
             OBContext.setAdminMode();
             try {
-              Window window = parameters.get("tab") == null
-                  || parameters.get("tab").equals("undefined") ? null : OBDal.getInstance()
-                  .get(Tab.class, parameters.get("tab")).getWindow();
+              Window window = parameters.get(JsonConstants.TAB_PARAMETER) == null
+                  || parameters.get(JsonConstants.TAB_PARAMETER).equals("undefined") ? null : OBDal
+                  .getInstance().get(Tab.class, parameters.get(JsonConstants.TAB_PARAMETER))
+                  .getWindow();
               String encoding = Preferences.getPreferenceValue("OBSERDS_CSVTextEncoding", true,
                   OBContext.getOBContext().getCurrentClient(), OBContext.getOBContext()
                       .getCurrentOrganization(), OBContext.getOBContext().getUser(), OBContext
@@ -299,8 +300,9 @@
         response.setHeader("Content-Disposition", "attachment; filename=ExportedData.csv");
         writer = response.getWriter();
         VariablesSecureApp vars = new VariablesSecureApp(request);
-        Window window = parameters.get("tab") == null || parameters.get("tab").equals("undefined") ? null
-            : OBDal.getInstance().get(Tab.class, parameters.get("tab")).getWindow();
+        Window window = parameters.get(JsonConstants.TAB_PARAMETER) == null
+            || parameters.get(JsonConstants.TAB_PARAMETER).equals("undefined") ? null : OBDal
+            .getInstance().get(Tab.class, parameters.get(JsonConstants.TAB_PARAMETER)).getWindow();
         try {
           prefDecimalSeparator = Preferences.getPreferenceValue("OBSERDS_CSVDecimalSeparator",
               true, OBContext.getOBContext().getCurrentClient(), OBContext.getOBContext()
@@ -414,8 +416,10 @@
               } else {
                 niceFieldProperties.put(propKey, col.getName());
               }
-            } else if (parameters.get("tab") != null && !parameters.get("tab").equals("")) {
-              Tab tab = OBDal.getInstance().get(Tab.class, parameters.get("tab"));
+            } else if (parameters.get(JsonConstants.TAB_PARAMETER) != null
+                && !parameters.get(JsonConstants.TAB_PARAMETER).equals("")) {
+              Tab tab = OBDal.getInstance().get(Tab.class,
+                  parameters.get(JsonConstants.TAB_PARAMETER));
               for (Field field : tab.getADFieldList()) {
                 if (field.getColumn() == null || !field.getColumn().getId().equals(col.getId())) {
                   continue;
@@ -685,9 +689,10 @@
       try {
         String csvMessage = null;
         try {
-          Window window = parameters.get("tab") == null
-              || parameters.get("tab").equals("undefined") ? null : OBDal.getInstance()
-              .get(Tab.class, parameters.get("tab")).getWindow();
+          Window window = parameters.get(JsonConstants.TAB_PARAMETER) == null
+              || parameters.get(JsonConstants.TAB_PARAMETER).equals("undefined") ? null : OBDal
+              .getInstance().get(Tab.class, parameters.get(JsonConstants.TAB_PARAMETER))
+              .getWindow();
           csvMessage = Preferences.getPreferenceValue(property, true, OBContext.getOBContext()
               .getCurrentClient(), OBContext.getOBContext().getCurrentOrganization(), OBContext
               .getOBContext().getUser(), OBContext.getOBContext().getRole(), window);