From 1eae34965fd7461fd68a82ad2ed41a485c904eff Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 31 Mar 2022 15:01:09 +0200 Subject: [PATCH] IDEMPIERE-4753 Make printing filename configurable / peer review (#1274) --- .../oracle/202203151632_IDEMPIERE-4753.sql | 56 +++++++++++++++++++ .../202203151632_IDEMPIERE-4753.sql | 56 +++++++++++++++++++ .../report/jasper/ReportStarter.java | 10 +++- .../adempiere/webui/window/ZkJRViewer.java | 2 +- .../webui/window/ZkReportViewer.java | 2 +- 5 files changed, 122 insertions(+), 4 deletions(-) rename migration/{iD10 => i9}/oracle/202203151632_IDEMPIERE-4753.sql (67%) rename migration/{iD10 => i9}/postgresql/202203151632_IDEMPIERE-4753.sql (67%) diff --git a/migration/iD10/oracle/202203151632_IDEMPIERE-4753.sql b/migration/i9/oracle/202203151632_IDEMPIERE-4753.sql similarity index 67% rename from migration/iD10/oracle/202203151632_IDEMPIERE-4753.sql rename to migration/i9/oracle/202203151632_IDEMPIERE-4753.sql index 81fd766bb7..9d63c63a8d 100644 --- a/migration/iD10/oracle/202203151632_IDEMPIERE-4753.sql +++ b/migration/i9/oracle/202203151632_IDEMPIERE-4753.sql @@ -83,4 +83,60 @@ INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,Displa ALTER TABLE AD_PrintFormat_Trl ADD FileNamePattern VARCHAR2(255 CHAR) DEFAULT NULL ; +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205584 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5762 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6503 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5657 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=170, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5661 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=180, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5654 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=190, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5658 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50179 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=210, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202368 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=230, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205242 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=240, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206663 +; + +-- Mar 31, 2022, 2:52:31 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206916 +; + +-- Mar 31, 2022, 2:52:31 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203046 +; + +-- Mar 31, 2022, 2:52:31 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=6, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203047 +; + SELECT register_migration_script('202203151632_IDEMPIERE-4753.sql') FROM dual; diff --git a/migration/iD10/postgresql/202203151632_IDEMPIERE-4753.sql b/migration/i9/postgresql/202203151632_IDEMPIERE-4753.sql similarity index 67% rename from migration/iD10/postgresql/202203151632_IDEMPIERE-4753.sql rename to migration/i9/postgresql/202203151632_IDEMPIERE-4753.sql index e103ca7754..5799174ae9 100644 --- a/migration/iD10/postgresql/202203151632_IDEMPIERE-4753.sql +++ b/migration/i9/postgresql/202203151632_IDEMPIERE-4753.sql @@ -80,4 +80,60 @@ INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,Displa ALTER TABLE AD_PrintFormat_Trl ADD COLUMN FileNamePattern VARCHAR(255) DEFAULT NULL ; +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205584 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5762 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6503 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5657 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=170, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5661 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=180, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5654 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=190, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5658 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50179 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=210, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202368 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET SeqNo=230, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205242 +; + +-- Mar 31, 2022, 2:51:46 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=240, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:51:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206663 +; + +-- Mar 31, 2022, 2:52:31 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206916 +; + +-- Mar 31, 2022, 2:52:31 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203046 +; + +-- Mar 31, 2022, 2:52:31 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=6, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-03-31 14:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203047 +; + SELECT register_migration_script('202203151632_IDEMPIERE-4753.sql') FROM dual; diff --git a/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java b/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java index 0b1b55a88c..0d9c3a8f3f 100644 --- a/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java +++ b/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java @@ -397,8 +397,14 @@ public class ReportStarter implements ProcessCall, ClientProcess } if (pi.getAD_Process_ID()>0) { MProcess process = new MProcess(Env.getCtx(), processInfo.getAD_Process_ID(), processInfo.getTransactionName()); - Language language = printFormat.getLanguage(); - String processFileNamePattern = printFormat.get_Translation("FileNamePattern", language.getAD_Language()); + String processFileNamePattern = null; + if (printFormat != null) { + Language language = printFormat.getLanguage(); + processFileNamePattern = printFormat.get_Translation("FileNamePattern", language.getAD_Language()); + } + if (processFileNamePattern == null && process.getFileNamePattern() != null) { + processFileNamePattern = process.getFileNamePattern(); + } if (process !=null && !Util.isEmpty(processFileNamePattern)) { String filename=FileUtil.parseTitle(Env.getCtx(), processFileNamePattern, pi.getTable_ID(), Record_ID, 0, trxName); pi.setTitle(filename); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java index 54c06a51bc..164aabd6a0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java @@ -887,7 +887,7 @@ public class ZkJRViewer extends Window implements EventListener, ITabOnCl MTable table = MTable.get(tableId); PO po = table.getPO(recordId, null); MAttachment attachment = po.createAttachment(); - String fileName = m_title.replace(" ", "_")+ "_" + m_printInfo.getName() + "." + media.getFormat(); + String fileName = m_title.replace(" ", "_") + "." + media.getFormat(); byte[] data = media.isBinary() ? media.getByteData() : media.getStringData().getBytes(); attachment.addEntry(fileName, data); success = attachment.save(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index baa4d4ae48..9b9b2b2eac 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -1379,7 +1379,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab PO po = table.getPO(recordId, null); MAttachment attachment = po.createAttachment(); byte[] data = media.isBinary() ? media.getByteData() : media.getStringData().getBytes(); - String fileName = m_reportEngine.getName().replace(" ", "_") + "_" + m_reportEngine.getPrintInfo().getName() + "." + media.getFormat(); + String fileName = m_reportEngine.getName().replace(" ", "_") + "." + media.getFormat(); attachment.addEntry(fileName, data); success = attachment.save(); if (success)