IDEMPIERE-1730 Counter Document can not create at Order and Invoice / integrate patch from Hagiwara Hideaki

This commit is contained in:
Carlos Ruiz 2014-03-12 21:03:05 -05:00
parent 6cb2efc029
commit 367ca9794e
2 changed files with 16 additions and 6 deletions

View File

@ -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());

View File

@ -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());