Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0042916Openbravo ERPA. Platformpublic2020-01-16 17:032020-01-22 18:36
AugustoMauch 
AugustoMauch 
normalminorhave not tried
closedfixed 
5
 
3.0PR20Q2 
caristu
Core
No
0042916: Selectors do not work properly in parameter windows if there are translations installed
When a parameter window has a grid parameter, and that grid parameter has a selector that points to a translatable property, the filter will not work properly if there are translations installed.

The fix for https://issues.openbravo.com/view.php?id=42915 [^] is required to reproduce this issue.
Make sure the fix of https://issues.openbravo.com/view.php?id=42915 [^] is applied
- Install the attached module.
- Install a translation pack (or edit OBContext.hasTranslationInstalled so that it always return true)
- Login, use any non-system role
- Open the Test Tree PW window.
- Click on the filter of the extraProductCategory column and select any value.
- The grid will be empty and the following error will be shown in the log:

2020-01-16 17:03:26,510 [http-nio-8080-exec-3] ERROR org.openbravo.service.datasource.DataSourceServlet - org.hibernate.QueryException: could not resolve property: extraProductCategory of: Product [select get_uuid() as id, p.name as name, p.productCategory as extraProductCategory from Product p WHERE p.client.id in ('0', :clientId) AND p.organization.id in ( :organizations ) AND (( upper((COALESCE(to_char((select p.name from ProductCategoryTrl as t where t.productCategory = p.extraProductCategory and t.language.language='en_US')), to_char(p.productCategory.name), ''))) = upper(:alias_0) )) ]
java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: extraProductCategory of: Product [select get_uuid() as id, p.name as name, p.productCategory as extraProductCategory from Product p WHERE p.client.id in ('0', :clientId) AND p.organization.id in ( :organizations ) AND (( upper((COALESCE(to_char((select p.name from ProductCategoryTrl as t where t.productCategory = p.extraProductCategory and t.language.language='en_US')), to_char(p.productCategory.name), ''))) = upper(:alias_0) )) ]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
    at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:729) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
    at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:745) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
    at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:104) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
    at org.openbravo.service.datasource.HQLDataSourceService.getQuery(HQLDataSourceService.java:368) ~[classes/:?]
    at org.openbravo.service.datasource.HQLDataSourceService.getData(HQLDataSourceService.java:190) ~[classes/:?]
    at org.openbravo.service.datasource.ReadOnlyDataSourceService.getSelectedData(ReadOnlyDataSourceService.java:168) ~[classes/:?]
    at org.openbravo.service.datasource.ReadOnlyDataSourceService.fetchJSONObject(ReadOnlyDataSourceService.java:147) ~[classes/:?]
    at org.openbravo.service.datasource.ReadOnlyDataSourceService.fetch(ReadOnlyDataSourceService.java:76) ~[classes/:?]
    at org.openbravo.service.datasource.DataSourceServlet.doFetch(DataSourceServlet.java:290) [classes/:?]
    at org.openbravo.service.datasource.DataSourceServlet.doPost(DataSourceServlet.java:837) [classes/:?]
No tags attached.
depends on defect 0042915 closed AugustoMauch Tree selector cannot be used in a parameter window that is opened from the menu 
zip org.openbravo.testtreeinpw.zip (14,651) 2020-01-16 17:04
https://issues.openbravo.com/file_download.php?file_id=13855&type=bug
Issue History
2020-01-16 17:03AugustoMauchNew Issue
2020-01-16 17:03AugustoMauchAssigned To => AugustoMauch
2020-01-16 17:03AugustoMauchModules => Core
2020-01-16 17:03AugustoMauchTriggers an Emergency Pack => No
2020-01-16 17:04AugustoMauchFile Added: org.openbravo.testtreeinpw.zip
2020-01-16 17:04AugustoMauchRelationship addeddepends on 0042915
2020-01-16 17:59AugustoMauchSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20155#r20155
2020-01-20 10:36hgbotCheckin
2020-01-20 10:36hgbotNote Added: 0117054
2020-01-20 10:36hgbotStatusnew => resolved
2020-01-20 10:36hgbotResolutionopen => fixed
2020-01-20 10:36hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/0fc6a0afc5916b86a15c55fcb311b0ec2d300b51 [^]
2020-01-22 18:36caristuReview Assigned To => caristu
2020-01-22 18:36caristuNote Added: 0117180
2020-01-22 18:36caristuStatusresolved => closed
2020-01-22 18:36caristuFixed in Version => 3.0PR20Q2

Notes
(0117054)
hgbot   
2020-01-20 10:36   
Repository: erp/devel/pi
Changeset: 0fc6a0afc5916b86a15c55fcb311b0ec2d300b51
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Mon Jan 20 10:22:29 2020 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/0fc6a0afc5916b86a15c55fcb311b0ec2d300b51 [^]

Fixes BUG-42916: Builds proper query for translated selector in param window

The query done when a selector done in a parameter window for a
translatable property did not work if there were transltations installed.

The query was being built like this:

SELECT get_uuid() as id, p.name as name, p.productCategory as extraProductCategory
FROM Product p
WHERE p.client.id in ('0', :clientId)
AND p.organization.id in ( :organizations )
AND (( upper((COALESCE(to_char((SELECT p.name
                                FROM ProductCategoryTrl as t
                                WHERE t.productCategory = p.extraProductCategory AND t.language.language='en_US')),
              to_char(p.productCategory.name), ''))) = upper(:alias_0) ))

The problem is here "t.productCategory = p.extraProductCategory". Product does not have an extraProductCategory property,
that's the alias of a column that should have been replaced here [1]. There were replacements in place for other similar cases
(i.e. p.alias.id -> placeholder.id, p.alias.name -> placeholder.name) but there is replacement missing when p.alias is found.

[1] https://gitlab.com/openbravo/product/openbravo/blob/52847f60/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java#L547 [^]

---
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java
---
(0117180)
caristu   
2020-01-22 18:36   
Reviewed + tested OK: https://gitlab.com/openbravo/product/openbravo/merge_requests/35/ [^]