Fixes issue 29224: Return reason filter works properly in Return from/to P&E
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 11 Mar 2015 11:07:30 +0100
changeset 26181 35265c987291
parent 26180 ee85914ad233
child 26182 f906f479f709
Fixes issue 29224: Return reason filter works properly in Return from/to P&E

The problem was that in this changeset [1] the way the distinct queries (done to populate the fk filter dropdowns) was modified. The query is different, and the way to process its results too. The regressi
on was caused because some HQL tables build their distinct queries manually in their HQL transformers, and those queries should have been updated too.

The query was changed the whole BaseOBObject in the first position of the result array, instead of including just its id.

[1] https://code.openbravo.com/erp/devel/pi/rev/95dd177fbbc7f18d448b3e31cc12b67dbc0cb87d
src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java
src/org/openbravo/common/datasource/ReturnToFromCustomerVendorOrphanHQLTransformer.java
--- a/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java	Fri Mar 13 17:39:41 2015 +0000
+++ b/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java	Wed Mar 11 11:07:30 2015 +0100
@@ -39,7 +39,7 @@
   private static final String returnedOthersLeftClause = " coalesce((select sum(ol.orderedQuantity) from OrderLine as ol left join ol.salesOrder as o where ol.goodsShipmentLine = iol and o.processed = true and o.documentStatus <> 'VO'), 0)";
   private static final String returnReasonLeftClause = " coalesce((select ol.returnReason.id from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), '')";
   private static final String returnReasonCountQuery = " select count(distinct e.name) from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId  and ol.goodsShipmentLine is not null) ";
-  private static final String returnReasonDataQuery = " select distinct e.id, e.name  from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is not null) ";
+  private static final String returnReasonDataQuery = " select distinct e, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is not null) ";
   private static final String unitPriceProperty = "unitPrice";
   private static final String grossUnitPriceProperty = "grossUnitPrice";
 
--- a/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorOrphanHQLTransformer.java	Fri Mar 13 17:39:41 2015 +0000
+++ b/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorOrphanHQLTransformer.java	Wed Mar 11 11:07:30 2015 +0100
@@ -34,7 +34,7 @@
 
   private static final String returnReasonLeftClause = " coalesce((select oli.returnReason.id from OrderLine as oli where oli.salesOrder.id = :salesOrderId  and oli.id=ol.id), '')";
   private static final String returnReasonCountQuery = " select count(distinct e.name) from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is null) ";
-  private static final String returnReasonDataQuery = " select distinct e.id, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is null) ";
+  private static final String returnReasonDataQuery = " select distinct e, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is null) ";
 
   @Override
   public String transformHqlQuery(String hqlQuery, Map<String, String> requestParameters,