From ad868d100cdda4d47154905074922c14b19b99ca Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 15 Dec 2017 18:42:01 +0800 Subject: [PATCH] IDEMPIERE-3654 1008749 Fix performance issue with bpartner field callout. --- .../src/org/compiere/model/CalloutOrder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 969e4d0a60..988520ff3e 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -250,15 +250,14 @@ public class CalloutOrder extends CalloutEngine + " p.SO_Description,p.IsDiscountPrinted," + " p.InvoiceRule,p.DeliveryRule,p.FreightCostRule,DeliveryViaRule," + " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," - + " lship.C_BPartner_Location_ID,c.AD_User_ID," + + " (select max(lship.C_BPartner_Location_ID) from C_BPartner_Location lship where p.C_BPartner_ID=lship.C_BPartner_ID AND lship.IsShipTo='Y' AND lship.IsActive='Y') as C_BPartner_Location_ID," + + " (select max(c.AD_User_ID) from AD_User c where p.C_BPartner_ID=c.C_BPartner_ID AND c.IsActive='Y') as AD_User_ID," + " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID," - + " lbill.C_BPartner_Location_ID AS Bill_Location_ID, p.SOCreditStatus, " + + " (select max(lbill.C_BPartner_Location_ID) from C_BPartner_Location lbill where p.C_BPartner_ID=lbill.C_BPartner_ID AND lbill.IsBillTo='Y' AND lbill.IsActive='Y') AS Bill_Location_ID, " + + " p.SOCreditStatus, " + " p.SalesRep_ID " + "FROM C_BPartner p" + " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)" - + " LEFT OUTER JOIN C_BPartner_Location lbill ON (p.C_BPartner_ID=lbill.C_BPartner_ID AND lbill.IsBillTo='Y' AND lbill.IsActive='Y')" - + " LEFT OUTER JOIN C_BPartner_Location lship ON (p.C_BPartner_ID=lship.C_BPartner_ID AND lship.IsShipTo='Y' AND lship.IsActive='Y')" - + " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID AND c.IsActive='Y') " + "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1 boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));