From 6ffc8721267385477343143485028441b9f307c0 Mon Sep 17 00:00:00 2001 From: tsvikruha Date: Mon, 3 Aug 2015 11:40:07 +0200 Subject: [PATCH] IDEMPIERE-2749 Internal Use Inventory - Document type Print Format ignored --- .../src/org/compiere/model/SystemIDs.java | 1 + .../src/org/compiere/print/ReportEngine.java | 25 ++++++++++++++++--- .../org/compiere/print/ServerReportCtl.java | 2 ++ .../src/org/compiere/print/ReportCtl.java | 3 +++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/SystemIDs.java b/org.adempiere.base/src/org/compiere/model/SystemIDs.java index 5685464606..a1eee0a94b 100644 --- a/org.adempiere.base/src/org/compiere/model/SystemIDs.java +++ b/org.adempiere.base/src/org/compiere/model/SystemIDs.java @@ -79,6 +79,7 @@ public class SystemIDs public final static int PROCESS_RPT_C_DUNNING = 159; public final static int PROCESS_RPT_FINREPORT = 202; public final static int PROCESS_RPT_FINSTATEMENT = 204; + public final static int PROCESS_RPT_M_INVENTORY = 291; public final static int REFERENCE_DATATYPE_ACCOUNT = 25; public final static int REFERENCE_DATATYPE_AMOUNT = 12; diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index 079afc9909..6cf688c663 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -17,6 +17,7 @@ package org.compiere.print; import static org.compiere.model.SystemIDs.TABLE_AD_TABLE; +import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INVENTORY; import java.awt.Color; import java.awt.Font; @@ -74,9 +75,11 @@ import org.compiere.model.MClient; import org.compiere.model.MColumn; import org.compiere.model.MDunningRunEntry; import org.compiere.model.MInOut; +import org.compiere.model.MInventory; import org.compiere.model.MInvoice; import org.compiere.model.MOrder; import org.compiere.model.MPaySelectionCheck; +import org.compiere.model.MProcess; import org.compiere.model.MProject; import org.compiere.model.MQuery; import org.compiere.model.MRfQResponse; @@ -1398,6 +1401,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) public static final int MANUFACTURING_ORDER = 8; /** Distribution Order = 9 */ public static final int DISTRIBUTION_ORDER = 9; + /** Physical Inventory = 10 */ + public static final int INVENTORY = 10; // private static final String[] DOC_TABLES = new String[] { @@ -1409,17 +1414,17 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) "C_Order", "M_InOut", "C_Invoice", "C_Project", "C_RfQResponse", "C_PaySelectionCheck", "C_PaySelectionCheck", - "C_DunningRunEntry","PP_Order", "DD_Order"}; + "C_DunningRunEntry","PP_Order", "DD_Order", "M_Inventory"}; private static final String[] DOC_IDS = new String[] { "C_Order_ID", "M_InOut_ID", "C_Invoice_ID", "C_Project_ID", "C_RfQResponse_ID", "C_PaySelectionCheck_ID", "C_PaySelectionCheck_ID", - "C_DunningRunEntry_ID" , "PP_Order_ID" , "DD_Order_ID" }; + "C_DunningRunEntry_ID" , "PP_Order_ID" , "DD_Order_ID", "M_Inventory_ID" }; private static final int[] DOC_TABLE_ID = new int[] { MOrder.Table_ID, MInOut.Table_ID, MInvoice.Table_ID, MProject.Table_ID, MRfQResponse.Table_ID, MPaySelectionCheck.Table_ID, MPaySelectionCheck.Table_ID, - MDunningRunEntry.Table_ID, X_PP_Order.Table_ID, MDDOrder.Table_ID }; + MDunningRunEntry.Table_ID, X_PP_Order.Table_ID, MDDOrder.Table_ID, MInventory.Table_ID }; /************************************************************************** * Get Document Print Engine for Document Type. @@ -1555,6 +1560,12 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) .append("WHERE d." + DOC_IDS[type] + "=?") // info from PrintForm .append(" AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ") .append("ORDER BY pf.AD_Org_ID DESC"); + else if (type == INVENTORY) + sql = new StringBuilder("SELECT COALESCE (dt.AD_PrintFormat_ID, 0), 0,") // 1..2 + .append(" NULL, 0 , d.DocumentNo ") // 3..5 + .append("FROM " + DOC_BASETABLES[type] + " d") + .append(" LEFT OUTER JOIN C_DocType dt ON (d.C_DocType_ID=dt.C_DocType_ID) ") + .append("WHERE d." + DOC_IDS[type] + "=?"); // info from PrintForm else // Get PrintFormat from Org or 0 of document client sql = new StringBuilder("SELECT pf.Order_PrintFormat_ID,pf.Shipment_PrintFormat_ID,") // 1..2 // Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org) // see InvoicePrint @@ -1583,7 +1594,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) if (rs.next()) // first record only { if (type == CHECK || type == DUNNING || type == REMITTANCE - || type == PROJECT || type == RFQ || type == MANUFACTURING_ORDER || type == DISTRIBUTION_ORDER) + || type == PROJECT || type == RFQ || type == MANUFACTURING_ORDER || type == DISTRIBUTION_ORDER + || type == INVENTORY) { AD_PrintFormat_ID = rs.getInt(1); copies = 1; @@ -1599,6 +1611,11 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) } else DocumentNo = rs.getString(5); + + if(AD_PrintFormat_ID == 0 && type == INVENTORY){ + MProcess process = MProcess.get(ctx, PROCESS_RPT_M_INVENTORY); + AD_PrintFormat_ID = process.getAD_PrintFormat_ID(); + } } else { diff --git a/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java b/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java index 048f883255..d3778fa169 100644 --- a/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java +++ b/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java @@ -201,6 +201,8 @@ public class ServerReportCtl { else if (pi.getAD_Process_ID() == 202 // Financial Report || pi.getAD_Process_ID() == 204) // Financial Statement return startFinReport (pi); + else if (pi.getAD_Process_ID() == 291) // M_Inventory + return startDocumentPrint(ReportEngine.INVENTORY, null, pi.getRecord_ID(), null, pi); /******************** * Standard Report *******************/ diff --git a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java index c857cf12d3..861ceaa49f 100644 --- a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java +++ b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java @@ -25,6 +25,7 @@ import static org.compiere.model.SystemIDs.PROCESS_RPT_C_RFQRESPONSE; import static org.compiere.model.SystemIDs.PROCESS_RPT_FINREPORT; import static org.compiere.model.SystemIDs.PROCESS_RPT_FINSTATEMENT; import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INOUT; +import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INVENTORY; import java.util.Properties; import java.util.logging.Level; @@ -155,6 +156,8 @@ public class ReportCtl return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PAYMENT) // C_Payment return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview()); + else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // Physical Inventory + return startDocumentPrint(ReportEngine.INVENTORY, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview()); /** else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint);