From 89ca4d1a813d5eeb51db5b9683ec3b31e4d74d7f Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Mon, 12 Oct 2009 06:54:10 +0000 Subject: [PATCH] BF [ 2876891 ] Improve doctype not found error https://sourceforge.net/tracker/?func=detail&aid=2876891&group_id=176962&atid=879335 --- base/src/org/compiere/model/MInvoice.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/base/src/org/compiere/model/MInvoice.java b/base/src/org/compiere/model/MInvoice.java index acd90c3c8c..277cba352a 100644 --- a/base/src/org/compiere/model/MInvoice.java +++ b/base/src/org/compiere/model/MInvoice.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.BPartnerNoAddressException; import org.adempiere.exceptions.DBException; import org.compiere.print.ReportEngine; @@ -290,10 +291,16 @@ public class MInvoice extends X_C_Invoice implements DocAction setClientOrg(order); setOrder(order); // set base settings // - if (C_DocTypeTarget_ID == 0) - C_DocTypeTarget_ID = DB.getSQLValue(null, - "SELECT C_DocTypeInvoice_ID FROM C_DocType WHERE C_DocType_ID=?", - order.getC_DocType_ID()); + if (C_DocTypeTarget_ID <= 0) + { + MDocType odt = MDocType.get(order.getCtx(), 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); if (invoiceDate != null) setDateInvoiced(invoiceDate);