From d53570eb75853eca4d657ccc1ae37fa8eefaab1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20Tak=C3=A1cs?=
<93127072+PeterTakacs300@users.noreply.github.com>
Date: Tue, 2 May 2023 11:13:55 +0200
Subject: [PATCH] IDEMPIERE-5695 - Process audit doesn't set print language,
format, print format on Forms/documents (#1805)
* IDEMPIERE-5695 - Process audit doesn't set print language, format, print format on Forms/documents
* IDEMPIERE-5695 - get language from print format
* IDEMPIERE-5695 - fix javadoc
* IDEMPIERE-5695 - implement in startStandardReport and startFinReport
---
.../src/org/compiere/model/MPInstance.java | 16 +++
.../src/org/compiere/print/ReportCtl.java | 110 +++++++++++++++---
2 files changed, 108 insertions(+), 18 deletions(-)
diff --git a/org.adempiere.base/src/org/compiere/model/MPInstance.java b/org.adempiere.base/src/org/compiere/model/MPInstance.java
index 86d06a4e1f..cfc89fec96 100644
--- a/org.adempiere.base/src/org/compiere/model/MPInstance.java
+++ b/org.adempiere.base/src/org/compiere/model/MPInstance.java
@@ -30,6 +30,7 @@ import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.event.EventManager;
+import org.compiere.print.MPrintFormat;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
@@ -664,4 +665,19 @@ public class MPInstance extends X_AD_PInstance
return true;
} // beforeSave
+
+ /**
+ * Set AD_PrintFormat_ID if empty, AD_Language_ID if empty and save the record.
+ * @param pf
+ */
+ public void updatePrintFormatAndLanguageIfEmpty(MPrintFormat format) {
+ if(getAD_PrintFormat_ID() <= 0 && format.getAD_PrintFormat_ID() > 0) {
+ setAD_PrintFormat_ID(format.getAD_PrintFormat_ID());
+ saveEx();
+ }
+ if(getAD_Language_ID() <= 0 && format.getLanguage() != null) {
+ setAD_Language_ID(MLanguage.get(Env.getCtx(), format.getLanguage()).getAD_Language_ID());
+ saveEx();
+ }
+ }
} // MPInstance
\ No newline at end of file
diff --git a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java
index 5d688a5670..4c19bed8fd 100644
--- a/org.adempiere.ui/src/org/compiere/print/ReportCtl.java
+++ b/org.adempiere.ui/src/org/compiere/print/ReportCtl.java
@@ -148,25 +148,25 @@ public class ReportCtl
* Order Print
*/
if (pi.getAD_Process_ID() == PROCESS_RPT_C_ORDER) // C_Order
- return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt PP_Order", null)) // C_Order
- return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.MANUFACTURING_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
if (pi.getAD_Process_ID() == MProcess.getProcess_ID("Rpt DD_Order", null)) // C_Order
- return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.DISTRIBUTION_ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_INVOICE) // C_Invoice
- return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INOUT) // M_InOut
- return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PROJECT) // C_Project
- return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_RFQRESPONSE) // C_RfQResponse
- return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
else if (pi.getAD_Process_ID() == PROCESS_RPT_C_PAYMENT) // C_Payment
- return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview());
+ return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview(), instance);
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_INVENTORY) // Physical Inventory
- return startDocumentPrint(ReportEngine.INVENTORY, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.INVENTORY, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
else if (pi.getAD_Process_ID() == PROCESS_RPT_M_MOVEMENT) // Inventory Move
- return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
+ return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview(), instance);
/**
else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ
return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint);
@@ -179,11 +179,11 @@ public class ReportCtl
return startDocumentPrint(ReportEngine.DUNNING, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == PROCESS_RPT_FINREPORT // Financial Report
|| pi.getAD_Process_ID() == PROCESS_RPT_FINSTATEMENT) // Financial Statement
- return startFinReport (pi, WindowNo);
+ return startFinReport (pi, WindowNo, instance);
/********************
* Standard Report
*******************/
- return startStandardReport (pi, WindowNo);
+ return startStandardReport (pi, WindowNo, instance);
}
finally {
instance.setIsProcessing(false);
@@ -212,6 +212,20 @@ public class ReportCtl
* @return true if OK
*/
static public boolean startStandardReport (ProcessInfo pi, int WindowNo, boolean IsDirectPrint)
+ {
+ return startStandardReport(pi, WindowNo, IsDirectPrint, null);
+ }
+
+ /**************************************************************************
+ * Start Standard Report.
+ * - Get Table Info and submit
+ * @param pi Process Info
+ * @param WindowNo The windows number which invoked the printing
+ * @param IsDirectPrint if true, prints directly - otherwise View
+ * @param instance - AD_PInstance
+ * @return true if OK
+ */
+ static public boolean startStandardReport (ProcessInfo pi, int WindowNo, boolean IsDirectPrint, MPInstance instance)
{
pi.setPrintPreview(!IsDirectPrint);
return startStandardReport(pi, WindowNo);
@@ -246,6 +260,24 @@ public class ReportCtl
* @return true if OK
*/
static public boolean startStandardReport (ProcessInfo pi, int WindowNo)
+ {
+ return startStandardReport(pi, WindowNo, null);
+ }
+
+ /**************************************************************************
+ * Start Standard Report.
+ * - Get Table Info and submit.
+ * A report can be created from:
+ *