Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0030900Openbravo ERPZ. Otherspublic2015-09-23 16:222015-09-23 16:22
rbianchini 
Triage Omni OMS 
normalminoralways
newopen 
5
3.0PR15Q1.4 
 
Core
No
0030900: Widget with null Date field cannot be exported
When a widget that has a date column that is an optional column which can be null, if you try to export the data to CSV, you will encounter a error that the CSV file contains only:

{"response":{"status":-4,"error":{"message":"Cannot format given Object as a
Date","type":"system"}}}



The stacktrace shows:

ERROR org.openbravo.service.datasource.DataSourceServlet - Cannot format
given Object as a Date

java.lang.IllegalArgumentException: Cannot format given Object as a Date

at java.text.DateFormat.format(DateFormat.java:281)

at java.text.Format.format(Format.java:140)

at
org.openbravo.client.querylist.QueryListDataSource.getData(QueryListDataSour
ce.java:270)

at
org.openbravo.service.datasource.ReadOnlyDataSourceService.fetchJSONObject(R
eadOnlyDataSourceService.java:137)

at
org.openbravo.service.datasource.ReadOnlyDataSourceService.fetch(ReadOnlyDat
aSourceService.java:116)

at
org.openbravo.service.datasource.DataSourceServlet.doFetch(DataSourceServlet
..java:251)

at
org.openbravo.service.datasource.DataSourceServlet.doPost(DataSourceServlet.
java:754)

and so on ..


Create a widjet with an optional column date which can be null.
Try to export to CSV
Observes the error in the CSV file
Apply this patch:
diff --git a/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java b/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
--- a/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
+++ b/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
@@ -267,9 +267,10 @@
                   || (!isExport && queryAliases[i].equals(column.getLinkExpression()))) {
                 Object value = resultList[i];
                 if (domainType instanceof DateDomainType || domainType instanceof DateDomainType) {
+ if (value != null) {
                     value = xmlDateFormat.format(value);
                   }
- else if (value instanceof Timestamp) {
+ } else if (value instanceof Timestamp) {
                   value = xmlDateTimeFormat.format(value);
                   value = JsonUtils.convertToCorrectXSDFormat((String) value);
                 }
No tags attached.
Issue History
2015-09-23 16:22rbianchiniNew Issue
2015-09-23 16:22rbianchiniAssigned To => Triage Finance
2015-09-23 16:22rbianchiniModules => Core
2015-09-23 16:22rbianchiniTriggers an Emergency Pack => No

There are no notes attached to this issue.