Openbravo Issue Tracking System - Retail Modules
View Issue Details
0034231Retail ModulesWeb POSpublic2016-10-18 12:102016-11-25 14:54
aaroncalero 
mario_castello 
highmajoralways
closedfixed 
5
 
RR17Q1 
marvintm
No
0034231: [SERQA 1966] PostProcess functions of dinamic SearchProductCharacteristicFilters are ignored after removing the filter
It is possible to define custom filters for the search tab from external modules (e.g. Stock Criteria, Complementary Products, ...). These filters might implement a postProcess function to change values on the searched products, or to show more information on the results (e.g. Stock Criteria shows a "Stock: #" label).
These filters can be added statically when the application is loaded (Stock or Price criteria) or dynamically when a specific filter is needed (Services, Complementary Products).
After a dynamic filter is removed from the search tab, postProcess functions of all dynamic filters stop working.
Login in a retail modules instance (e.g. https://livebuilds.openbravo.com/retail_modules_pgsql_pi/web/org.openbravo.retail.posterminal/?terminal=CMS-1 [^])
Use the developer tools to execute the following code:
OBRECP_SearchProductCharacteristicFilter.extend({
  postProcess: function (products, callback, queryWasExecutedOnline) {
    products.forEach(function(item){
      item.set('standardPrice', 9999);
      item.set('listPrice', 9999);
    })
    callback(queryWasExecutedOnline)
  }
})

OB.UI.SearchServicesFilter.extend({
  postProcess: function (products, callback, queryWasExecutedOnline) {
    var me = this;
    products.forEach(function(item){
      me.addItemAttributes(item, "TEST: " + item.get('_identifier'));
    })
    callback(queryWasExecutedOnline)
  }
})

Create a new ticket and add the following products:
Thermal jacket
GPS Nano
Click on the complementary products button of the Thermal Jacket. Verify that the price of the complementary products is 9999.
Click on the related services button of the GPS Nano. Verify that there is a "TEST: <product name>" label on the search results.
Remove the services filter (click on the X of the yellow text on top of the search tab).
Repeat the steps and verify that the price of the complementary products isn't 9999 anymore, and that the "TEST: <product name>" label doesn't appear either.
The postProcess functions are managed using an array named postProcessCustomFilters defined on the OB.UI.SearchProductCharacteristic kind.
The problem seems to be related with the fact that sometimes the prototype definition is used (OB.UI.SearchProductCharacteristic.prototype) to manage the postProcess functions, while in other occasions an OB.UI.SearchProductCharacteristic instance is used (e.g. when removing a filter).
One possible solution is to make the postProcessCustomFilters array static, and access it using the following notation: OB.UI.SearchProductCharacteristic.postProcessCustomFilters everywhere (attached patch with this option)
SER-QA
diff Issue34231.diff (2,227) 2016-10-18 12:11
https://issues.openbravo.com/file_download.php?file_id=9928&type=bug
Issue History
2016-10-18 12:10aaroncaleroNew Issue
2016-10-18 12:10aaroncaleroAssigned To => Retail
2016-10-18 12:10aaroncaleroResolution time => 1477954800
2016-10-18 12:10aaroncaleroTriggers an Emergency Pack => No
2016-10-18 12:11aaroncaleroFile Added: Issue34231.diff
2016-10-18 12:14aaroncaleroTag Attached: SER-QA
2016-10-18 12:15aaroncaleroSummaryPostProcess functions of dinamic SearchProductCharacteristicFilters are ignored after removing the filter => [SERQA 1966] PostProcess functions of dinamic SearchProductCharacteristicFilters are ignored after removing the filter
2016-10-28 09:12marvintmResolution time1477954800 => 1478818800
2016-11-07 13:12marvintmResolution time1478818800 => 1479423600
2016-11-16 16:31mario_castelloAssigned ToRetail => mario_castello
2016-11-16 16:32mario_castelloStatusnew => acknowledged
2016-11-18 21:30hgbotCheckin
2016-11-18 21:30hgbotNote Added: 0091664
2016-11-18 21:30hgbotStatusacknowledged => resolved
2016-11-18 21:30hgbotResolutionopen => fixed
2016-11-18 21:30hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/0da6b627d7a0dc98b694263eb582a171647bc4f2 [^]
2016-11-18 21:32hgbotCheckin
2016-11-18 21:32hgbotNote Added: 0091665
2016-11-25 14:54marvintmReview Assigned To => marvintm
2016-11-25 14:54marvintmStatusresolved => closed
2016-11-25 14:54marvintmFixed in Version => RR17Q1

Notes
(0091664)
hgbot   
2016-11-18 21:30   
Repository: erp/pmods/org.openbravo.mobile.core
Changeset: 0da6b627d7a0dc98b694263eb582a171647bc4f2
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Wed Nov 16 13:30:59 2016 -0600
URL: http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/0da6b627d7a0dc98b694263eb582a171647bc4f2 [^]

Fixed issue 34231: Created an static array postProcessCustomFilters to stored the filters

---
M web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
---
(0091665)
hgbot   
2016-11-18 21:32   
Repository: tools/automation/pi-mobile
Changeset: 0bcaf91b590411b2ada69d3adde14d0b569b0795
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Wed Nov 16 16:27:03 2016 -0600
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/0bcaf91b590411b2ada69d3adde14d0b569b0795 [^]

Verifies issue 34231: Added automated test I34231_VerifySearchProductCharacteristicFilters

---
M src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
A src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/products/I34231_VerifySearchProductCharacteristicFilters.java
---