Fixes issue 40782: Standard properties are taken from underlying window in P&E
authorAugusto Mauch <augusto.mauch@openbravo.com>
Mon, 06 May 2019 16:47:56 +0200
changeset 35629 aa8cc9d96cad
parent 35628 0ec858b516d0
child 35630 5a9355cfa0e6
Fixes issue 40782: Standard properties are taken from underlying window in P&E

When a P&E window contains a grid and a request to the datasource of the P&E window is done, it is
not clear whether the P&E grid or the underlying grid standard properties (tabId, tableId, windowId, etc)
should be included in the contextInfo.

Before this changeset [1] was pushed, the standard properties were taken from the underlying grid. The
changeset modified the behaviour, so that the P&E grid standard properties were included instead.
This was necessary because the SelectorConstants.includeOrgFilter method needed the table ID of the
P&E grid.

But the change caused another problem: Some OBBindings were relying on the underlying grid standard
properties being included in the contextInfo.

To fix both problems, now a new property called inpPickAndExecuteTableId is included when doing a
request from a P&E grid, and that property is referenced by SelectorConstants.includeOrgFilter.

The contextInfo now will include the standard properties of the underlying grid, as it was done
before [1].

[1] https://code.openbravo.com/erp/devel/pi/rev/1ed089db27e7036cf53026ca873dbcf104d79bb9
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorConstants.java
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Mon May 06 16:46:57 2019 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Mon May 06 16:47:56 2019 +0200
@@ -925,7 +925,9 @@
       return;
     }
     contextInfo = isc.addProperties({}, this.view.parentWindow.activeView.getContextInfo(false, true, true, true));
-    isc.addProperties(contextInfo, this.viewProperties.standardProperties);
+    if (this.viewProperties.standardProperties && this.viewProperties.standardProperties.inpTableId) {
+      contextInfo.inpPickAndExecuteTableId = this.viewProperties.standardProperties.inpTableId;
+    }
     record = isc.addProperties({}, this.getRecord(rowNum), this.getEditValues(rowNum));
     fields = this.viewProperties.fields;
     len = fields.length;
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorConstants.java	Mon May 06 16:46:57 2019 +0200
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorConstants.java	Mon May 06 16:47:56 2019 +0200
@@ -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-2017 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2019 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -47,6 +47,7 @@
   public static final String PARAM_ID_FILTERS = "idFilters";
   public static final String PARAM_FILTER_EXPRESSION = "filterExpression";
   private static final String PARAM_TABLE_ID = "inpTableId";
+  private static final String PARAM_PICK_AND_EXECUTE_TABLE_ID = "inpPickAndExecuteTableId";
 
   // Reference definition IDs
   public static final String SELECTOR_REFERENCE_ID = "95E2A8B50A254B2AAE6774B8C2F28120";
@@ -69,8 +70,10 @@
         && parameters.containsKey(PARAM_TABLE_ID)
         && parameters.containsKey(PARAM_TARGET_PROPERTY_NAME);
     if (isSelector) {
-      Entity entity = ModelProvider.getInstance()
-          .getEntityByTableId(parameters.get(PARAM_TABLE_ID));
+      String tableId = parameters.containsKey(PARAM_PICK_AND_EXECUTE_TABLE_ID)
+          ? parameters.get(PARAM_PICK_AND_EXECUTE_TABLE_ID)
+          : parameters.get(PARAM_TABLE_ID);
+      Entity entity = ModelProvider.getInstance().getEntityByTableId(tableId);
       if (entity != null) {
         Property property = entity.getProperty(parameters.get(PARAM_TARGET_PROPERTY_NAME), false);
         return property != null && !property.isAllowedCrossOrgReference();