Fixed bug 38422: Characteristic description selector not working with filter.
authorJavier Armendáriz <javier.armendariz@openbravo.com>
Mon, 30 Apr 2018 14:07:14 +0200
changeset 33920 f2979bad6889
parent 33919 e298e83db301
child 33921 a1b63a73a71d
Fixed bug 38422: Characteristic description selector not working with filter.

Product characteristics filter assumes the parentGridEntity is always a Product,
but for the Add Product dialog, it is a ProductWithCharacteristics entity. In this
case it is needed to add a reference to a Product instance to make filtering
work as expected.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-characteristics.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-characteristics.js	Fri May 04 09:13:06 2018 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-characteristics.js	Mon Apr 30 14:07:14 2018 +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) 2013-2016 Openbravo SLU
+ * All portions are Copyright (C) 2013-2018 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -527,6 +527,9 @@
     // previous to the last one 
     if (this.grid && this.grid.parentElement && this.grid.parentElement.viewProperties && this.grid.parentElement.viewProperties.gridProperties && this.grid.parentElement.viewProperties.gridProperties.alias) {
       this.propertyName = this.grid.parentElement.viewProperties.gridProperties.alias;
+      if (!this.isProductEntity()) {
+        this.propertyName += '.product';
+      }
     } else {
       this.propertyName = 'e'; // "e" is the base entity
     }
@@ -566,6 +569,23 @@
     this.Super('init', arguments);
   },
 
+  isProductEntity: function () {
+    var entity, theGrid;
+
+    if (this.grid && !this.grid.sourceWidget) {
+      return false; // can not retrieve entity
+    }
+    theGrid = this.grid.sourceWidget;
+    if (theGrid.view && theGrid.view.entity) {
+      // Standard view
+      entity = theGrid.view.entity;
+    } else if (theGrid.viewProperties && theGrid.viewProperties.entity) {
+      // Pick and Edit view
+      entity = theGrid.viewProperties.entity;
+    }
+    return entity === 'Product';
+  },
+
   removeProductCharacteristicsCriteria: function (fullCriteria) {
     var newCriteria = isc.shallowClone(fullCriteria);
     if (fullCriteria.criteria && fullCriteria.criteria.find('isProductCharacteristicsCriteria', true)) {