Fixes issue 29224: Filters work properly in Return from/to P&E window
authorAugusto Mauch <>
Wed, 11 Mar 2015 11:07:30 +0100
changeset 26182 f906f479f709
parent 26181 35265c987291
child 26183 30bc648fab8b
child 26184 4a5316fc24e1
Fixes issue 29224: Filters work properly in Return from/to P&E window

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 change done in the result processing caused this issue. The query done to populate the Attribute Set Value drop down is the following:

select distinct attributeSetValue,attributeSetValue.description FROM MaterialMgmtShipmentInOutLine as iol left join iol.attributeSetValue as attributeSetValue join iol.shipmentReceipt as io where = 'A6750F0D15334FB890C254369AC750A8' and io.processed = true and io.documentStatus <> 'VO' and io.salesTransaction = true and (select iol.salesOrderLine.orderDiscount from MaterialMgmtShipmentInOutLine as e where = iol) is null and in ('0', '23C59575B9CF467C9620760EB255B389') AND iol.organization in ('E443A31992CB4635AFCAEABE7183CE85','0','19404EAD144C49A0AF37D54377CF452D','B843C30461EA4501935CB1D125C9C25A') AND (io.movementDate >= (now() - 90) or (case when (select ('Y') from OrderLine as ol where = 'F0D6700E7BD6499FA76C6D94014714E8' and ol.goodsShipmentLine = iol) is null then false else true end) = true) ORDER BY attributeSetValue.description

And this is the result returned in the test I did:

1 42EA0E631BDD4ED69D8C30723A5E81C8 [identifier: L582, entity: AttributeSetInstance], L582

With the previous way of processing the results the second record was ignored, but with the new one a NPE was being thrown.

--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/	Wed Mar 11 11:07:30 2015 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/	Wed Mar 11 11:07:30 2015 +0100
@@ -182,6 +182,9 @@
         Object[] result = (Object[]) row;
         // the whole referenced BaseOBObject is stored in the first position of the result
         BaseOBObject bob = (BaseOBObject) result[0];
+        if (bob == null) {
+          break;
+        }
         record.put(JsonConstants.ID, bob.getId());
         record.put(JsonConstants.IDENTIFIER, IdentifierProvider.getInstance().getIdentifier(bob));
       } else {