Openbravo Issue Tracking System - Retail Modules
View Issue Details
0031268Retail ModulesWeb POSpublic2015-10-27 13:272015-10-28 16:06
adrianromero 
adrianromero 
urgentmajorhave not tried
closedfixed 
5
 
RR16Q1 
marvintm
No
0031268: SimpleQueryBuilder replacement order of criterias is incorrect.
The order of replacement tags provided by SimpleQueryBuilder is not correct.

The problem is that $filtersCriteria and $hqlCriteria are the last tags to be replaced but the filters defined in $filtersCriteria and $hqlCriteria may contain tags that has been replaced previously so will not be replaced
This is the current order of replacement in getHQLQuery()
https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/file/8e517c8e2c1c/src/org/openbravo/mobile/core/process/SimpleQueryBuilder.java#l429 [^]

For example filtering Business Partners in the Business Partners list in POS, the LocName (Localization Name) property includes the tags $naturalOrgCriteria and $readableSimpleClientCriteria that are not processed because the $filtersCriteria is replaced at the end ant the following error is raised:


serviceSuccess error: status: -1, error.message: unexpected AST node: . near line 34, column 725 [SELECT bpl.businessPartner.id as id,
bpl.businessPartner.organization.id as organization,
bpl.businessPartner.name as name,
bpl.businessPartner.name as _identifier,
bpl.businessPartner.searchKey as searchKey,
bpl.businessPartner.description as description,
bpl.businessPartner.taxID as taxID,
bpl.businessPartner.sOBPTaxCategory.id as taxCategory,
bpl.businessPartner.priceList.id as priceList,
bpl.businessPartner.paymentMethod.id as paymentMethod,
bpl.businessPartner.paymentTerms.id as paymentTerms,
bpl.businessPartner.invoiceTerms as invoiceTerms,
(select max(bpls.id) as bpLocId from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.invoiceToAddress = true and ( (bpls.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpls.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) group by bpls.businessPartner.id) as locId,
(select max(bpls.id) as bpLocId from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.shipToAddress = true and ( (bpls.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpls.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) group by bpls.businessPartner.id) as locShipId,
(select max(COALESCE(bpls.locationAddress.addressLine1, bpls.locationAddress.addressLine2, bpls.locationAddress.postalCode, bpls.locationAddress.cityName)) from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.invoiceToAddress = true and ( (bpls.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpls.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) group by bpls.businessPartner.id) as locName,
(select max(COALESCE(bpls.locationAddress.addressLine1, bpls.locationAddress.addressLine2, bpls.locationAddress.postalCode, bpls.locationAddress.cityName)) as nameShipTo from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.shipToAddress = true and ( (bpls.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpls.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) group by bpls.businessPartner.id) as locShipName,
ulist.email as email,
ulist.id as contactId,
ulist.phone as phone,
ulist.firstName as firstName,
ulist.lastName as lastName,
plist.priceIncludesTax as priceIncludesTax,
plist.name as priceListName,
(select max(bpls.locationAddress.cityName) from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.shipToAddress = true and ( (bpls.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpls.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) group by bpls.businessPartner.id) as cityName,
(select max(bpls.locationAddress.postalCode) from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.shipToAddress = true and ( (bpls.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpls.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) group by bpls.businessPartner.id) as postalCode,
bpl.locationAddress.country.name as countryName,
bpl.businessPartner.businessPartnerCategory.id as businessPartnerCategory,
bpl.businessPartner.businessPartnerCategory.name as businessPartnerCategory_name,
bpl.businessPartner.creditLimit as creditLimit,
bpl.businessPartner.creditUsed as creditUsed,
bpl.businessPartner.taxExempt as taxExempt,
bpl.businessPartner.customerBlocking as customerBlocking,
bpl.businessPartner.salesOrder as salesOrderBlocking,
(case when bpl.active = 'Y' and bpl.businessPartner.active = 'Y' then true else false end) as active FROM BusinessPartnerLocation AS bpl left outer join bpl.businessPartner.aDUserList AS ulist left outer join bpl.businessPartner.priceList AS plist WHERE ( (upper(bpl.businessPartner.searchKey) like upper('b%') OR upper(bpl.businessPartner.name) like upper('b%') OR upper(bpl.businessPartner.taxID) like upper('b%') OR upper((select max(COALESCE(bpls.locationAddress.addressLine1, bpls.locationAddress.addressLine2, bpls.locationAddress.postalCode, bpls.locationAddress.cityName)) as nameShipTo from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.shipToAddress = true and bpls.$readableSimpleClientCriteria AND bpls.$naturalOrgCriteria group by bpls.businessPartner.id)) like upper('b%') OR upper((select max(COALESCE(bpls.locationAddress.addressLine1, bpls.locationAddress.addressLine2, bpls.locationAddress.postalCode, bpls.locationAddress.cityName)) from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and bpls.invoiceToAddress = true and bpls.$readableSimpleClientCriteria AND bpls.$naturalOrgCriteria group by bpls.businessPartner.id)) like upper('b%') OR upper(ulist.phone) like upper('b%') OR upper(ulist.email) like upper('b%')) ) AND bpl.businessPartner.customer = true AND bpl.businessPartner.priceList IS NOT NULL AND ( (bpl.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpl.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) AND (( (bpl.active = 'Y') ) AND ( (bpl.businessPartner.active = 'Y') )) and bpl.id in (select max(bpls.id) as bpLocId from BusinessPartnerLocation AS bpls where bpls.businessPartner.id=bpl.businessPartner.id and ( (bpls.client.id in ('39363B0921BB4293B48383844325E84C', '0')) ) AND (bpls.organization.id in ('D270A5AC50874F8BA67A88EE977F8E3B', '0', '14B1927026BE471E9B85FE699BCA61C2', '67839EEFA49E44AC969BD60093FCC899', 'BF129721D9FB4EB0819509934153E972')) group by bpls.businessPartner.id) and (not exists (select 1 from ADUser usr where usr.businessPartner = bpl.businessPartner)) ORDER BY bpl.businessPartner.name]; line: serviceSuccess (http://localhost:8080/openbravo/web/js/gen/5a4256db9f784eed43bd8859d6f8b899_WebPOS.js:1033:10 [^]) (*,+)
Put the lines that executes the replacement of $filtersCriteria and $hqlCriteria at the very beginning of the method getHQLQuery() in class SimpleQueryBuilder

See the attached diff.
No tags attached.
diff issue31268.diff (1,608) 2015-10-27 13:38
https://issues.openbravo.com/file_download.php?file_id=8649&type=bug
Issue History
2015-10-27 13:27adrianromeroNew Issue
2015-10-27 13:27adrianromeroAssigned To => adrianromero
2015-10-27 13:27adrianromeroTriggers an Emergency Pack => No
2015-10-27 13:37adrianromeroProposed Solution updated
2015-10-27 13:38adrianromeroFile Added: issue31268.diff
2015-10-27 13:58adrianromeroReview Assigned To => marvintm
2015-10-27 16:03hgbotCheckin
2015-10-27 16:03hgbotNote Added: 0081355
2015-10-27 16:03hgbotStatusnew => resolved
2015-10-27 16:03hgbotResolutionopen => fixed
2015-10-27 16:03hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/5f300c6e16595af756e66bc3eb88d89d737c2d08 [^]
2015-10-28 16:06marvintmStatusresolved => closed
2015-10-28 16:06marvintmFixed in Version => RR16Q1

Notes
(0081355)
hgbot   
2015-10-27 16:03   
Repository: erp/pmods/org.openbravo.mobile.core
Changeset: 5f300c6e16595af756e66bc3eb88d89d737c2d08
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Tue Oct 27 13:34:35 2015 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/5f300c6e16595af756e66bc3eb88d89d737c2d08 [^]

Fixes issue 0031268: SimpleQueryBuilder replacement order of criterias is incorrect.
* and are moved to the begining of the method getHQLQuery() to avoid dependency problems

---
M src/org/openbravo/mobile/core/process/SimpleQueryBuilder.java
---