From 5cfb8bce61648b32b4db136c6f40ed1e8f73a0b9 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 24 Aug 2016 15:03:55 +0200 Subject: [PATCH] IDEMPIERE-3159 Importing Orders / Invoices implicitly creating BPs fail to see BPs already created in the same import process / integrate patch contributed by Daniel Haag (dhdx) --- .../org/compiere/process/ImportInvoice.java | 2 +- .../src/org/compiere/process/ImportOrder.java | 2 +- .../src/org/compiere/model/MBPartner.java | 32 ++++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java b/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java index 081b246a79..137b6fc424 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java @@ -525,7 +525,7 @@ public class ImportInvoice extends SvrProcess imp.setName (imp.getBPartnerValue ()); } // BPartner - MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue()); + MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue(), get_TrxName()); if (bp == null) { bp = new MBPartner (getCtx (), -1, get_TrxName()); diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java b/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java index bcf3992bb2..4f1c6347c2 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java @@ -525,7 +525,7 @@ public class ImportOrder extends SvrProcess imp.setName (imp.getBPartnerValue ()); } // BPartner - MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue()); + MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue(), get_TrxName()); if (bp == null) { bp = new MBPartner (getCtx (), -1, get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/MBPartner.java b/org.adempiere.base/src/org/compiere/model/MBPartner.java index 28adf4c002..c91dee9980 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartner.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartner.java @@ -47,7 +47,7 @@ public class MBPartner extends X_C_BPartner /** * */ - private static final long serialVersionUID = -5503105554864289337L; + private static final long serialVersionUID = -803727877324075871L; /** * Get Empty Template Business Partner @@ -110,12 +110,23 @@ public class MBPartner extends X_C_BPartner * @param Value value * @return BPartner or null */ - public static MBPartner get (Properties ctx, String Value) + public static MBPartner get (Properties ctx, String Value) { + return get(ctx,Value,null); + } + + /** + * Get BPartner with Value in a transaction + * @param ctx context + * @param Value value + * @param trxName transaction + * @return BPartner or null + */ + public static MBPartner get (Properties ctx, String Value, String trxName) { if (Value == null || Value.length() == 0) return null; final String whereClause = "Value=? AND AD_Client_ID=?"; - MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, null) + MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, trxName) .setParameters(Value,Env.getAD_Client_ID(ctx)) .firstOnly(); return retValue; @@ -128,9 +139,22 @@ public class MBPartner extends X_C_BPartner * @return BPartner or null */ public static MBPartner get (Properties ctx, int C_BPartner_ID) + { + return get(ctx,C_BPartner_ID,null); + } + + + /** + * Get BPartner with Value in a transaction + * @param ctx context + * @param Value value + * @param trxName transaction + * @return BPartner or null + */ + public static MBPartner get (Properties ctx, int C_BPartner_ID, String trxName) { final String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?"; - MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause,null) + MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause,trxName) .setParameters(C_BPartner_ID,Env.getAD_Client_ID(ctx)) .firstOnly(); return retValue;