fixes issue 39896: Not possible to filter by characteristic in Create Lines
authorCarlos Aristu <carlos.aristu@openbravo.com>
Tue, 15 Jan 2019 13:57:46 +0100
changeset 35318 41b709331d14
parent 35317 00f3ad11d13d
child 35319 0520ead34ebb
fixes issue 39896: Not possible to filter by characteristic in Create Lines

The changeset[1] was not taking into account the possibility of having a field with a name that already contains 'product'. This can happen when having a property field like: product.characteristicDescription.

In that case an extra 'product' was being added to the propery path which resulted in a wrong HQL where clause definition for the characteristic filter.

Now we do not append 'product' to the property path in case it already starts with it.

[1] https://code.openbravo.com/erp/devel/pi/rev/f2979bad688953ced9571ab74cf312c989a0f81b
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	Mon Jan 14 12:10:40 2019 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-characteristics.js	Tue Jan 15 13:57:46 2019 +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-2018 Openbravo SLU
+ * All portions are Copyright (C) 2013-2019 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -527,7 +527,7 @@
     // 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()) {
+      if (!this.isProductEntity() && !this.isPropertyPathFromProduct(this.getFieldName())) {
         this.propertyName += '.product';
       }
     } else {
@@ -586,6 +586,10 @@
     return entity === 'Product';
   },
 
+  isPropertyPathFromProduct: function (propertyName) {
+    return propertyName.startsWith('product' + OB.Constants.FIELDSEPARATOR);
+  },
+
   removeProductCharacteristicsCriteria: function (fullCriteria) {
     var newCriteria = isc.shallowClone(fullCriteria);
     if (fullCriteria.criteria && fullCriteria.criteria.find('isProductCharacteristicsCriteria', true)) {