From f74e6c78246ec2c65a4c38a04c39e4045f966deb Mon Sep 17 00:00:00 2001 From: igorpojzl <59439434+igorpojzl@users.noreply.github.com> Date: Thu, 22 Apr 2021 21:13:10 +0200 Subject: [PATCH] IDEMPIERE-4709 - Print Format Item: implement script column (expression) (#644) * IDEMPIERE-4709 - Print Format Item: implement script column (expression) * IDEMPIERE-4709 - Translated comments * IDEMPIERE-4709 - Check Advanced Access, Null Script before save * IDEMPIERE-4709 - Changed Naming Changed Naming for Scripts. * IDEMPIERE-4709 Remove Migration script mistake * IDEMPIERE-4709 Logic and Value Name Fixes --- .../oracle/202102201441_IDEMPIERE-4709.sql | 44 ++++++ .../202102201441_IDEMPIERE-4709.sql | 40 ++++++ org.adempiere.base/plugin.xml | 11 ++ .../model/CalloutPrintFormatType.java | 29 ++++ .../print/export/PrintDataExcelExporter.java | 6 + .../compiere/model/I_AD_PrintFormatItem.java | 13 ++ .../compiere/model/X_AD_PrintFormatItem.java | 21 ++- .../src/org/compiere/print/DataEngine.java | 132 +++++++++++++++++- .../org/compiere/print/MPrintFormatItem.java | 22 +++ .../src/org/compiere/print/ReportEngine.java | 16 ++- .../compiere/print/layout/LayoutEngine.java | 21 ++- 11 files changed, 348 insertions(+), 7 deletions(-) create mode 100644 migration/i8.2z/oracle/202102201441_IDEMPIERE-4709.sql create mode 100644 migration/i8.2z/postgresql/202102201441_IDEMPIERE-4709.sql create mode 100644 org.adempiere.base/src/org/adempiere/model/CalloutPrintFormatType.java diff --git a/migration/i8.2z/oracle/202102201441_IDEMPIERE-4709.sql b/migration/i8.2z/oracle/202102201441_IDEMPIERE-4709.sql new file mode 100644 index 0000000000..f195930dde --- /dev/null +++ b/migration/i8.2z/oracle/202102201441_IDEMPIERE-4709.sql @@ -0,0 +1,44 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Feb 20, 2021, 1:45:25 PM BRT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200504,'Script',255,'S',0,0,'Y',TO_DATE('2021-02-20 13:45:25','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-02-20 13:45:25','YYYY-MM-DD HH24:MI:SS'),100,'D','f3acb050-7407-481a-9177-022c134cf3a5') +; + +-- Feb 20, 2021, 1:46:44 PM BRT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (214413,0,'Script','Dynamic Java Language Script to calculate result','Use Java language constructs to define the result of the calculation',489,'Script',2000,'N','N','N','N','N',0,'N',14,0,0,'Y',TO_DATE('2021-02-20 13:46:44','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-02-20 13:46:44','YYYY-MM-DD HH24:MI:SS'),100,1718,'Y','N','D','N','N','N','Y','d0873a87-64d0-4d21-bf51-5b5b6ce1645a','Y',0,'N','N','N') +; + +-- Feb 20, 2021, 1:46:46 PM BRT +ALTER TABLE AD_PrintFormatItem ADD Script VARCHAR2(2000 CHAR) DEFAULT NULL +; + +-- Feb 20, 2021, 1:51:41 PM BRT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan,NumLines) VALUES (206598,'Script','Dynamic Java Language Script to calculate result','Use Java language constructs to define the result of the calculation',426,214413,'Y',2000,570,'N','N','N','N',0,0,'Y',TO_DATE('2021-02-20 13:51:41','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-02-20 13:51:41','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','c0a3c732-4ea1-4597-8a6f-c26cac7715e6','Y',570,5,3) +; + +-- Feb 20, 2021, 1:51:58 PM BRT +UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:51:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598 +; + +-- Feb 20, 2021, 1:52:53 PM BRT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@PrintFormatType@=''S''', IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:52:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5668 +; + +-- Feb 20, 2021, 1:58:50 PM BRT +UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=F | @PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:58:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56373 +; + +-- Feb 20, 2021, 1:59:31 PM BRT +UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, MandatoryLogic='@PrintFormatType@=S', IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:59:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598 +; + +-- Feb 20, 2021, 2:00:40 PM BRT +UPDATE AD_Field SET AD_FieldGroup_ID=200015, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 14:00:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598 +; + + + + +SELECT register_migration_script('202102201441_IDEMPIERE-4709.sql') FROM dual +; diff --git a/migration/i8.2z/postgresql/202102201441_IDEMPIERE-4709.sql b/migration/i8.2z/postgresql/202102201441_IDEMPIERE-4709.sql new file mode 100644 index 0000000000..04cee79657 --- /dev/null +++ b/migration/i8.2z/postgresql/202102201441_IDEMPIERE-4709.sql @@ -0,0 +1,40 @@ +-- Feb 20, 2021, 1:45:25 PM BRT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200504,'Script',255,'S',0,0,'Y',TO_TIMESTAMP('2021-02-20 13:45:25','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-02-20 13:45:25','YYYY-MM-DD HH24:MI:SS'),100,'D','f3acb050-7407-481a-9177-022c134cf3a5') +; + +-- Feb 20, 2021, 1:46:44 PM BRT +INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (214413,0,'Script','Dynamic Java Language Script to calculate result','Use Java language constructs to define the result of the calculation',489,'Script',2000,'N','N','N','N','N',0,'N',14,0,0,'Y',TO_TIMESTAMP('2021-02-20 13:46:44','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-02-20 13:46:44','YYYY-MM-DD HH24:MI:SS'),100,1718,'Y','N','D','N','N','N','Y','d0873a87-64d0-4d21-bf51-5b5b6ce1645a','Y',0,'N','N','N') +; + +-- Feb 20, 2021, 1:46:46 PM BRT +ALTER TABLE AD_PrintFormatItem ADD COLUMN Script VARCHAR(2000) DEFAULT NULL +; + +-- Feb 20, 2021, 1:51:41 PM BRT +INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan,NumLines) VALUES (206598,'Script','Dynamic Java Language Script to calculate result','Use Java language constructs to define the result of the calculation',426,214413,'Y',2000,570,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-02-20 13:51:41','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-02-20 13:51:41','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','c0a3c732-4ea1-4597-8a6f-c26cac7715e6','Y',570,5,3) +; + +-- Feb 20, 2021, 1:51:58 PM BRT +UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:51:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598 +; + +-- Feb 20, 2021, 1:52:53 PM BRT +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@PrintFormatType@=''S''', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:52:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5668 +; + +-- Feb 20, 2021, 1:58:50 PM BRT +UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=F | @PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:58:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56373 +; + +-- Feb 20, 2021, 1:59:31 PM BRT +UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, MandatoryLogic='@PrintFormatType@=S', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:59:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598 +; + +-- Feb 20, 2021, 2:00:40 PM BRT +UPDATE AD_Field SET AD_FieldGroup_ID=200015, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 14:00:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598 +; + + + +SELECT register_migration_script('202102201441_IDEMPIERE-4709.sql') FROM dual +; diff --git a/org.adempiere.base/plugin.xml b/org.adempiere.base/plugin.xml index 91943b4fc5..3a0ebf1ab9 100644 --- a/org.adempiere.base/plugin.xml +++ b/org.adempiere.base/plugin.xml @@ -94,6 +94,17 @@ tableName="AD_InfoColumn"> + + + + + m_summarized = new HashMap(); /************************************************************************** * Load Data @@ -272,11 +279,12 @@ public class DataEngine .append("pfi.IsVarianceCalc, pfi.IsDeviationCalc, ") // 22..23 .append("c.ColumnSQL, COALESCE(pfi.FormatPattern, c.FormatPattern) ") // 24, 25 //BEGIN http://jira.idempiere.com/browse/IDEMPIERE-153 - .append(" , pfi.isDesc ") //26 + /** START DEVCOFFEE: script column **/ + .append(" , pfi.isDesc, pfi.Script, pfi.Name ") //26 //END .append("FROM AD_PrintFormat pf") .append(" INNER JOIN AD_PrintFormatItem pfi ON (pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID)") - .append(" INNER JOIN AD_Column c ON (pfi.AD_Column_ID=c.AD_Column_ID)") + .append(" LEFT JOIN AD_Column c ON (pfi.AD_Column_ID=c.AD_Column_ID)") .append(" LEFT OUTER JOIN AD_ReportView_Col rvc ON (pf.AD_ReportView_ID=rvc.AD_ReportView_ID AND c.AD_Column_ID=rvc.AD_Column_ID) ") .append("WHERE pf.AD_PrintFormat_ID=?") // #1 .append(" AND pfi.IsActive='Y' AND (pfi.IsPrinted='Y' OR c.IsKey='Y' OR pfi.SortNo > 0 ") @@ -288,6 +296,8 @@ public class DataEngine + MPrintFormatItem.PRINTFORMATTYPE_Image + "','" + MPrintFormatItem.PRINTFORMATTYPE_PrintFormat + + "','" + + MPrintFormatItem.PRINTFORMATTYPE_Script + "') ") .append("ORDER BY pfi.IsPrinted DESC, pfi.SeqNo"); // Functions are put in first column PreparedStatement pstmt = null; @@ -373,6 +383,10 @@ public class DataEngine //BEGIN http://jira.idempiere.com/browse/IDEMPIERE-153 boolean isDesc = "Y".equals(rs.getString(26)); //END + /** START DEVCOFFEE: script column **/ + String script = rs.getString(27); + String pfiName = rs.getString(28); + // Fully qualified Table.Column for ordering String orderName = tableName + "." + ColumnName; @@ -387,6 +401,31 @@ public class DataEngine groupByColumns.add(tableName+"."+ColumnName); pdc = new PrintDataColumn(AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, KEY, isPageBreak); // KeyColumn } + /** START DEVCOFFEE: script column **/ + else if (ColumnName == null || script != null && !script.isEmpty()) + { + // => (..) AS AName, Table.ID, + if (script != null && !script.isEmpty()) + { + if (script.startsWith("@SQL=")) + { + script = "(" + script.replace("@SQL=", "") + ")"; + } + else + script = "'@SCRIPT" + script + "'"; + } + else + script = ""; + + if (ColumnName == null && script.isEmpty()) + continue; + + sqlSELECT.append(script).append(" AS ").append(m_synonym).append(pfiName).append(",") + .append("''").append(" AS ").append(pfiName).append(","); + // + pdc = new PrintDataColumn(-1, pfiName, DisplayType.Text, FieldLength, orderName, isPageBreak); + synonymNext(); + } // -- Parent, TableDir (and unqualified Search) -- else if ( /* (IsParent && DisplayType.isLookup(AD_Reference_ID)) || <-- IDEMPIERE-71 Carlos Ruiz - globalqss */ AD_Reference_ID == DisplayType.TableDir @@ -763,7 +802,13 @@ public class DataEngine length++; } else + { cc++; + // Refs #6532 + if (cc == 'X') + cc++; + } + // m_synonym = String.valueOf(cc); for (int i = 1; i < length; i++) { @@ -998,8 +1043,23 @@ public class DataEngine String id = rs.getString(counter++); if (display != null && !rs.wasNull()) { + /** START DEVCOFFEE: script column **/ + int displayType = pdc.getDisplayType(); + if (display.startsWith("@SCRIPT")) + { + displayType = DisplayType.Number; + display = display.replace("@SCRIPT", ""); + display = parseVariable(display, pdc, pd); + Interpreter bsh = new Interpreter (); + try { + display = bsh.eval(display).toString(); + } catch (EvalError e) { + log.severe(e.getMessage()); + } + } + ValueNamePair pp = new ValueNamePair(id, display); - pde = new PrintDataElement(pdc.getColumnName(), pp, pdc.getDisplayType(), pdc.getFormatPattern()); + pde = new PrintDataElement(pdc.getColumnName(), pp, displayType, pdc.getFormatPattern()); } } } @@ -1226,7 +1286,71 @@ public class DataEngine } // two lines } // printRunningTotal - + /** + * Parse expression, replaces @tag@ with pdc values and/or execute functions + * @param expression + * @param pdc + * @param pd + * @return String + */ + public String parseVariable(String expression, PrintDataColumn pdc, PrintData pd) { + if (expression == null || expression.length() == 0) + return ""; + + log.info("Analyzing Expression " + expression); + String token; + String inStr = new String(expression); + StringBuffer outStr = new StringBuffer(); + int i = inStr.indexOf('@'); + while (i != -1) + { + outStr.append(inStr.substring(0, i)); // up to @ + inStr = inStr.substring(i+1, inStr.length()); // from first @ + + int j = inStr.indexOf('@'); // next @ + if (j < 0) + { + return ""; // no second tag + } + + token = inStr.substring(0, j); + + //format string + int f = token.indexOf('<'); + if (f > 0 && token.endsWith(">")) { + token = token.substring(0, f); + } + + if (token.startsWith("ACCUMULATE/")) { + + token = token.replace("ACCUMULATE/", ""); + + BigDecimal value = (BigDecimal) ((PrintDataElement)pd.getNode(token)).getValue(); + + if (m_summarized.containsKey(pdc)) + { + value= ((BigDecimal) m_summarized.get(pdc)).add(value); + m_summarized.remove(pdc); + } + + m_summarized.put(pdc, value); + + outStr.append(value); + } + else if (token.startsWith("COL/")) + { + token = token.replace("COL/", ""); + BigDecimal value = (BigDecimal) ((PrintDataElement)pd.getNode(token)).getValue(); + outStr.append(value); + } + + inStr = inStr.substring(j+1, inStr.length()); // from second @ + i = inStr.indexOf('@'); + } + outStr.append(inStr); // add the rest of the string + + return outStr.toString(); + } /************************************************************************* * Test * @param args args diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java b/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java index 7aeda03c3f..5f31a30c8d 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormatItem.java @@ -24,6 +24,7 @@ import java.util.Properties; import java.util.logging.Level; import org.compiere.model.GridField; +import org.compiere.model.MRole; import org.compiere.model.X_AD_PrintFormatItem; import org.compiere.util.CCache; import org.compiere.util.CLogger; @@ -31,6 +32,8 @@ import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Language; +import org.compiere.util.Msg; +import org.compiere.util.Util; import org.idempiere.cache.ImmutablePOSupport; /** @@ -246,6 +249,14 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem implements ImmutableP } } // loadTranslations + /** + * Type Script + * @return true if script + */ + public boolean isTypeScript() + { + return getPrintFormatType().equals(PRINTFORMATTYPE_Script); + } /** * Type Field @@ -721,6 +732,17 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem implements ImmutableP if (!isTypeField() && !isTypePrintFormat() && !isImageField()) { setAD_Column_ID(0); } + + if(!isTypeScript() && !Util.isEmpty(getScript())) { + setScript(null); + } + + if(!Util.isEmpty(getScript()) && is_ValueChanged(MPrintFormatItem.COLUMNNAME_Script) + && getScript().contains("@SQL") && !MRole.getDefault().isAccessAdvanced()) { + log.saveError("Error", Msg.getMsg(getCtx(), "ActionNotAllowedHere")); + return false; + } + return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index a25e0e17eb..2e545d6087 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -849,7 +849,16 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) { td td = new td(); tr.addElement(td); - Object obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID())); + Object obj = null; + /** START DEVCOFFEE: script column **/ + if (item.isTypeScript()) + { + obj = m_printData.getNode(item.getName()); + } + else + { + obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID())); + } if (obj == null || !isDisplayPFItem(item)){ td.addElement(" "); if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){ @@ -1067,6 +1076,11 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) printColIndex++; Object obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID())); String data = ""; + /** START DEVCOFFEE: script column **/ + if (item.isTypeScript()) + { + obj = m_printData.getNode(item.getName()); + } if (obj == null || !isDisplayPFItem(item)){ if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){ preValues[printColIndex] = null; diff --git a/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java b/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java index ffecfbb5f5..57521e270c 100644 --- a/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java +++ b/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java @@ -1145,6 +1145,13 @@ public class LayoutEngine implements Pageable, Printable, Doc element.setMaxWidth(maxWidth); } } + /** START DEVCOFFEE: Script print format type **/ + else if (item.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Script)) + { + element = createStringElement (item.getName(), + item.getAD_PrintColor_ID (), item.getAD_PrintFont_ID (), + maxWidth, item.getMaxHeight (), item.isHeightOneLine (), alignment, true); + } else // (item.isTypeText()) //** Text { String printName = item.getPrintName (m_format.getLanguage ()); @@ -1246,6 +1253,13 @@ public class LayoutEngine implements Pageable, Printable, Doc newLine(); PrintElement element = null; // + // COF #10540 - avoid error when generating PDF due to inconsistency in the configuration + if (item.getAD_PrintFormatChild_ID() <= 0) + { + log.log(Level.SEVERE, "Included format not configured. AD_PrintFormat_ID = " + item.getAD_PrintFormat_ID() + ", AD_PrintFormatItem_ID=" + item.getAD_PrintFormatItem_ID()); + return element; + } + MPrintFormat format = MPrintFormat.get (getCtx(), item.getAD_PrintFormatChild_ID(), false); format.setLanguage(m_format.getLanguage()); if (m_format.isTranslationView()) @@ -1800,11 +1814,16 @@ public class LayoutEngine implements Pageable, Printable, Doc { columnElement = item.getPrintName(format.getLanguage()); } - else if (item.isTypeField()) + else if (item.isTypeField() || item.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Script)) { Object obj = null; if (item.getAD_Column_ID() > 0) // teo_sarca, [ 1673542 ] obj = printData.getNode(Integer.valueOf(item.getAD_Column_ID())); + /** START DEVCOFFEE: Script print format type **/ + if (item.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Script)) + { + obj = printData.getNode(item.getName()); + } if (obj == null) ; else if (obj instanceof PrintDataElement)