[Tree Extension] Obtains properly the tab and entity in TreeDatasourceService
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 06 Feb 2014 10:41:03 +0100
changeset 22504 aa96c53ec27d
parent 22503 d3e9610a24ee
child 22505 470f9cbb581d
[Tree Extension] Obtains properly the tab and entity in TreeDatasourceService
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java	Thu Feb 06 10:40:10 2014 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/TreeDatasourceService.java	Thu Feb 06 10:41:03 2014 +0100
@@ -146,8 +146,14 @@
       // datasource
       if (parameters.containsKey(JsonConstants.DISTINCT_PARAMETER)) {
         String tabId = parameters.get("_tabId");
-        Tab tab = OBDal.getInstance().get(Tab.class, tabId);
-        Entity entity = ModelProvider.getInstance().getEntityByTableId(tab.getTable().getId());
+        String tableId = parameters.get("_tableId");
+        Entity entity = null;
+        if (tabId != null) {
+          Tab tab = OBDal.getInstance().get(Tab.class, tabId);
+          entity = ModelProvider.getInstance().getEntityByTableId(tab.getTable().getId());
+        } else if (tableId != null) {
+          entity = ModelProvider.getInstance().getEntityByTableId(tableId);
+        }
         DataSourceService dataSource = dataSourceServiceProvider.getDataSource(entity.getName());
         return dataSource.fetch(parameters);
       }