Fixes BUG-42915: Tree selectors can be used in menu parameter windows
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 16 Jan 2020 17:24:21 +0100
changeset 36962 aab954878646
parent 36961 16059e5842d1
child 36963 0fc6a0afc591
Fixes BUG 42915: Tree selectors can be used in menu parameter windows

The problem was that the code in OBTreeItemPopupFilterWindow.copyFunctionsFromGrid was assuming that the
grid where the selector has placed had a view that also had a viewGrid. This is not the case in grids that
are parameters in parameter windows that are open directly from the menu.

What the function does is to copy from functions from OBViewGrid to OBTreeItemPopupFilterWindow. For this
it does not need any real instance of viewGrid, any instance works. Because there is no real instance
available in this type of parameter windows, the issue has been fixed by creating a dummy one like this:

if (grid == null) {
grid = isc.OBViewGrid.create({ fields: [], view: {} });
}
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js	Fri Jan 17 15:02:42 2020 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js	Thu Jan 16 17:24:21 2020 +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) 2013-2019 Openbravo SLU
+ * All portions are Copyright (C) 2013-2020 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -115,6 +115,11 @@
       },
 
       copyFunctionsFromGrid: function(grid) {
+        if (grid == null) {
+          // need a grid just to copy some functions
+          // if none is available, create a dummy one
+          grid = isc.OBViewGrid.create({ fields: [], view: {} });
+        }
         this.filterEditorProperties = grid.filterEditorProperties;
         this.checkShowFilterFunnelIcon = grid.checkShowFilterFunnelIcon;
         this.isGridFiltered = grid.isGridFiltered;
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Jan 17 15:02:42 2020 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Thu Jan 16 17:24:21 2020 +0100
@@ -554,7 +554,10 @@
     }
 
     // only personalize if there is a professional license
-    if (!OB.Utilities.checkProfessionalLicense(null, true)) {
+    if (
+      !OB.Utilities.checkProfessionalLicense(null, true) &&
+      this.view.standardWindow
+    ) {
       vwState = this.view.standardWindow.getDefaultGridViewState(
         this.view.tabId
       );