BF [ 2876891 ] Improve doctype not found error

https://sourceforge.net/tracker/?func=detail&aid=2876891&group_id=176962&atid=879335
This commit is contained in:
teo_sarca 2009-10-12 06:54:10 +00:00
parent b62e1fa858
commit 89ca4d1a81
1 changed files with 11 additions and 4 deletions

View File

@ -27,6 +27,7 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.BPartnerNoAddressException; import org.adempiere.exceptions.BPartnerNoAddressException;
import org.adempiere.exceptions.DBException; import org.adempiere.exceptions.DBException;
import org.compiere.print.ReportEngine; import org.compiere.print.ReportEngine;
@ -290,10 +291,16 @@ public class MInvoice extends X_C_Invoice implements DocAction
setClientOrg(order); setClientOrg(order);
setOrder(order); // set base settings setOrder(order); // set base settings
// //
if (C_DocTypeTarget_ID == 0) if (C_DocTypeTarget_ID <= 0)
C_DocTypeTarget_ID = DB.getSQLValue(null, {
"SELECT C_DocTypeInvoice_ID FROM C_DocType WHERE C_DocType_ID=?", MDocType odt = MDocType.get(order.getCtx(), order.getC_DocType_ID());
order.getC_DocType_ID()); if (odt != null)
{
C_DocTypeTarget_ID = odt.getC_DocTypeInvoice_ID();
if (C_DocTypeTarget_ID <= 0)
throw new AdempiereException("@NotFound@ @C_DocTypeInvoice_ID@ - @C_DocType_ID@:"+odt.get_Translation(MDocType.COLUMNNAME_Name));
}
}
setC_DocTypeTarget_ID(C_DocTypeTarget_ID); setC_DocTypeTarget_ID(C_DocTypeTarget_ID);
if (invoiceDate != null) if (invoiceDate != null)
setDateInvoiced(invoiceDate); setDateInvoiced(invoiceDate);