diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java index 0f6c48b1a8..0adede9787 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java @@ -159,7 +159,18 @@ public class CalloutInvoice extends CalloutEngine { // get default PriceList int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); if (i != 0) - mTab.setValue("M_PriceList_ID", new Integer(i)); + { + MPriceList pl = new MPriceList(ctx, i, null); + if (IsSOTrx == pl.isSOPriceList()) + mTab.setValue("M_PriceList_ID", new Integer(i)); + else + { + String sql2 = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql2, Env.getAD_Client_ID(ctx), IsSOTrx); + if (ii != 0) + mTab.setValue("M_PriceList_ID", new Integer(ii)); + } + } } // PaymentRule 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 241b8c4858..8a5c2359e6 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -289,7 +289,18 @@ public class CalloutOrder extends CalloutEngine { // get default PriceList int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); if (i != 0) - mTab.setValue("M_PriceList_ID", new Integer(i)); + { + MPriceList pl = new MPriceList(ctx, i, null); + if (IsSOTrx == pl.isSOPriceList()) + mTab.setValue("M_PriceList_ID", new Integer(i)); + else + { + String sql2 = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql2, Env.getAD_Client_ID(ctx), IsSOTrx); + if (ii != 0) + mTab.setValue("M_PriceList_ID", new Integer(ii)); + } + } } // Bill-To @@ -494,7 +505,18 @@ public class CalloutOrder extends CalloutEngine { // get default PriceList int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); if (i != 0) - mTab.setValue("M_PriceList_ID", new Integer(i)); + { + MPriceList pl = new MPriceList(ctx, i, null); + if (IsSOTrx == pl.isSOPriceList()) + mTab.setValue("M_PriceList_ID", new Integer(i)); + else + { + String sql2 = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql2, Env.getAD_Client_ID(ctx), IsSOTrx); + if (ii != 0) + mTab.setValue("M_PriceList_ID", new Integer(ii)); + } + } } int bill_Location_ID = rs.getInt("Bill_Location_ID"); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 53c83e5daa..e9c0f166c6 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -925,11 +925,16 @@ public class MInvoice extends X_C_Invoice implements DocAction { int ii = Env.getContextAsInt(getCtx(), "#M_PriceList_ID"); if (ii != 0) - setM_PriceList_ID(ii); - else { - String sql = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsDefault='Y'"; - ii = DB.getSQLValue (null, sql, getAD_Client_ID()); + MPriceList pl = new MPriceList(getCtx(), ii, null); + if (isSOTrx() == pl.isSOPriceList()) + setM_PriceList_ID(ii); + } + + if (getM_PriceList_ID() == 0) + { + String sql = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql, getAD_Client_ID(), isSOTrx()); if (ii != 0) setM_PriceList_ID (ii); }