From 367ca9794ed82882f7fb550152ae6e0faae9d88e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 12 Mar 2014 21:03:05 -0500 Subject: [PATCH] IDEMPIERE-1730 Counter Document can not create at Order and Invoice / integrate patch from Hagiwara Hideaki --- .../src/org/compiere/model/MInvoice.java | 9 +++++++-- .../src/org/compiere/model/MOrder.java | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 069c02478d..ec73c55afe 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -163,6 +163,11 @@ public class MInvoice extends X_C_Invoice implements DocAction if (counter) { to.setRef_Invoice_ID(from.getC_Invoice_ID()); + MOrg org = MOrg.get(from.getCtx(), from.getAD_Org_ID()); + int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(trxName); + if (counterC_BPartner_ID == 0) + return null; + to.setBPartner(MBPartner.get(from.getCtx(), counterC_BPartner_ID)); // Try to find Order link if (from.getC_Order_ID() != 0) { @@ -2169,8 +2174,8 @@ public class MInvoice extends X_C_Invoice implements DocAction counter.setAD_Org_ID(counterAD_Org_ID); // counter.setM_Warehouse_ID(counterOrgInfo.getM_Warehouse_ID()); // - counter.setBPartner(counterBP); - // Refernces (Should not be required +// counter.setBPartner(counterBP);// was set on copyFrom + // References (Should not be required) counter.setSalesRep_ID(getSalesRep_ID()); counter.saveEx(get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index aea06a3374..2d89d4454f 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -127,9 +127,14 @@ public class MOrder extends X_C_Order implements DocAction to.setIsTransferred (false); to.setPosted (false); to.setProcessed (false); - if (counter) + if (counter) { to.setRef_Order_ID(from.getC_Order_ID()); - else + MOrg org = MOrg.get(from.getCtx(), from.getAD_Org_ID()); + int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(trxName); + if (counterC_BPartner_ID == 0) + return null; + to.setBPartner(MBPartner.get(from.getCtx(), counterC_BPartner_ID)); + } else to.setRef_Order_ID(0); // if (!to.save(trxName)) @@ -2338,9 +2343,9 @@ public class MOrder extends X_C_Order implements DocAction counter.setAD_Org_ID(counterAD_Org_ID); counter.setM_Warehouse_ID(counterOrgInfo.getM_Warehouse_ID()); // - counter.setBPartner(counterBP); +// counter.setBPartner(counterBP); // was set on copyFrom counter.setDatePromised(getDatePromised()); // default is date ordered - // Refernces (Should not be required + // References (Should not be required) counter.setSalesRep_ID(getSalesRep_ID()); counter.saveEx(get_TrxName());