From 9c5045333efe6b2910600d6e595c86dee90856c3 Mon Sep 17 00:00:00 2001 From: Silvano Trinchero Date: Tue, 10 Apr 2018 17:12:02 +0200 Subject: [PATCH 1/8] Fix chiusura file nel merge dei pdf --- .../src/org/adempiere/webui/apps/AEnv.java | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index ec5f896301..034b53b650 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.lang.ref.WeakReference; import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.List; @@ -592,27 +593,43 @@ public final class AEnv DocumentException, FileNotFoundException { Document document = null; PdfWriter copy = null; - for (File f : pdfList) - { - PdfReader reader = new PdfReader(f.getAbsolutePath()); - if (document == null) + + List pdfReaders = new ArrayList(); + + try + { + for (File f : pdfList) { - document = new Document(reader.getPageSizeWithRotation(1)); - copy = PdfWriter.getInstance(document, new FileOutputStream(outFile)); - document.open(); + PdfReader reader = new PdfReader(f.getAbsolutePath()); + + pdfReaders.add(reader); + + if (document == null) + { + document = new Document(reader.getPageSizeWithRotation(1)); + copy = PdfWriter.getInstance(document, new FileOutputStream(outFile)); + document.open(); + } + int pages = reader.getNumberOfPages(); + PdfContentByte cb = copy.getDirectContent(); + for (int i = 1; i <= pages; i++) { + document.newPage(); + copy.newPage(); + PdfImportedPage page = copy.getImportedPage(reader, i); + cb.addTemplate(page, 0, 0); + copy.releaseTemplate(page); + } } - int pages = reader.getNumberOfPages(); - PdfContentByte cb = copy.getDirectContent(); - for (int i = 1; i <= pages; i++) { - document.newPage(); - copy.newPage(); - PdfImportedPage page = copy.getImportedPage(reader, i); - cb.addTemplate(page, 0, 0); - copy.releaseTemplate(page); + document.close(); + } + finally + { + for(PdfReader reader:pdfReaders) + { + reader.close(); } } - document.close(); - } + } /** * Get window title From c3727c2f109348cc82fbb4480cf12f29cd146e83 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 12 Apr 2018 17:08:14 +0200 Subject: [PATCH 2/8] IDEMPIERE-3685 Client field is shown empty in Included Roles grid mode --- migration/i5.1/oracle/201804121657_IDEMPIERE-3685.sql | 11 +++++++++++ .../i5.1/postgresql/201804121657_IDEMPIERE-3685.sql | 8 ++++++++ .../adempiere/webui/adwindow/GridTabRowRenderer.java | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 migration/i5.1/oracle/201804121657_IDEMPIERE-3685.sql create mode 100644 migration/i5.1/postgresql/201804121657_IDEMPIERE-3685.sql diff --git a/migration/i5.1/oracle/201804121657_IDEMPIERE-3685.sql b/migration/i5.1/oracle/201804121657_IDEMPIERE-3685.sql new file mode 100644 index 0000000000..b1578a80b7 --- /dev/null +++ b/migration/i5.1/oracle/201804121657_IDEMPIERE-3685.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3685 +-- Apr 12, 2018 4:51:48 PM CEST +UPDATE AD_Tab SET WhereClause='(AD_Field.IsDisplayed=''Y'' OR AD_Field.IsDisplayedGrid=''Y'')', OrderByClause='AD_Field.SeqNo, AD_Field.SeqNoGrid',Updated=TO_DATE('2018-04-12 16:51:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=107 +; + +SELECT register_migration_script('201804121657_IDEMPIERE-3685.sql') FROM dual +; + diff --git a/migration/i5.1/postgresql/201804121657_IDEMPIERE-3685.sql b/migration/i5.1/postgresql/201804121657_IDEMPIERE-3685.sql new file mode 100644 index 0000000000..4dab3d3c60 --- /dev/null +++ b/migration/i5.1/postgresql/201804121657_IDEMPIERE-3685.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-3685 +-- Apr 12, 2018 4:51:48 PM CEST +UPDATE AD_Tab SET WhereClause='(AD_Field.IsDisplayed=''Y'' OR AD_Field.IsDisplayedGrid=''Y'')', OrderByClause='SeqNo, SeqNoGrid',Updated=TO_TIMESTAMP('2018-04-12 16:51:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=107 +; + +SELECT register_migration_script('201804121657_IDEMPIERE-3685.sql') FROM dual +; + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java index afbf8d835f..39a8f79726 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java @@ -567,7 +567,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt } GridRowCtx ctx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex); - if (!gridPanelFields[i].isDisplayed(ctx, true)){ + if (! (gridPanelFields[i].isDisplayed(ctx, true) || gridPanelFields[i].isDisplayedGrid())){ // IDEMPIERE-2253 component.setVisible(false); } From f0bab73c31131f4ae92f114a8b5a1be2ff598653 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 12 Apr 2018 19:01:50 +0200 Subject: [PATCH 3/8] IDEMPIERE-3684 Reports exported to Excel don't use ZK_FOOTER_SERVER_ / integrate patch from Nicolas Micoud (nmicoud) --- .../adempiere/impexp/AbstractExcelExporter.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/adempiere/impexp/AbstractExcelExporter.java b/org.adempiere.base/src/org/adempiere/impexp/AbstractExcelExporter.java index 3e39c0f8a5..3a4bd374d4 100644 --- a/org.adempiere.base/src/org/adempiere/impexp/AbstractExcelExporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/AbstractExcelExporter.java @@ -19,6 +19,7 @@ import java.io.OutputStream; import java.sql.Timestamp; import java.text.DecimalFormat; import java.text.NumberFormat; +import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Properties; import java.util.logging.Level; @@ -34,6 +35,7 @@ import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.DisplayType; import org.compiere.util.Env; @@ -339,9 +341,20 @@ public abstract class AbstractExcelExporter // Sheet Footer HSSFFooter footer = sheet.getFooter(); footer.setLeft(Env.getStandardReportFooterTrademarkText()); - footer.setCenter(Env.getHeader(getCtx(), 0)); + + String s = MSysConfig.getValue(MSysConfig.ZK_FOOTER_SERVER_MSG, "", Env.getAD_Client_ID(Env.getCtx())); + if (Util.isEmpty(s)) + footer.setCenter(Env.getHeader(getCtx(), 0)); + else + footer.setCenter(Msg.parseTranslation(Env.getCtx(), s)); + Timestamp now = new Timestamp(System.currentTimeMillis()); - footer.setRight(DisplayType.getDateFormat(DisplayType.DateTime, getLanguage()).format(now)); + s = MSysConfig.getValue(MSysConfig.ZK_FOOTER_SERVER_DATETIME_FORMAT, Env.getAD_Client_ID(Env.getCtx())); + if (!Util.isEmpty(s)) + footer.setRight(new SimpleDateFormat(s).format(System.currentTimeMillis())); + else + footer.setRight(DisplayType.getDateFormat(DisplayType.DateTime, getLanguage()).format(now)); + } protected void formatPage(HSSFSheet sheet) From 6f5f225d6659b0c5d23c133c9a4c1b892a903d89 Mon Sep 17 00:00:00 2001 From: Nicolas Micoud Date: Tue, 17 Apr 2018 09:26:12 +0200 Subject: [PATCH 4/8] IDEMPIERE-3691 "Row" tooltip is not translated --- migration/i5.1/oracle/201804170900_IDEMPIERE-3691.sql | 10 ++++++++++ .../i5.1/postgresql/201804170900_IDEMPIERE-3691.sql | 7 +++++++ .../adempiere/webui/adwindow/GridTabRowRenderer.java | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 migration/i5.1/oracle/201804170900_IDEMPIERE-3691.sql create mode 100644 migration/i5.1/postgresql/201804170900_IDEMPIERE-3691.sql diff --git a/migration/i5.1/oracle/201804170900_IDEMPIERE-3691.sql b/migration/i5.1/oracle/201804170900_IDEMPIERE-3691.sql new file mode 100644 index 0000000000..f9fcf03b7b --- /dev/null +++ b/migration/i5.1/oracle/201804170900_IDEMPIERE-3691.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3691 "Row" tooltip is not translated +-- Apr 17, 2018 9:04:04 AM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Row',0,0,'Y',TO_DATE('2018-04-17 09:04:03','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2018-04-17 09:04:03','YYYY-MM-DD HH24:MI:SS'),0,200452,'Row','D','df5d9baf-0fd2-477c-aa27-da90069bbd07') +; + +SELECT register_migration_script('201804170900_IDEMPIERE-3691.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i5.1/postgresql/201804170900_IDEMPIERE-3691.sql b/migration/i5.1/postgresql/201804170900_IDEMPIERE-3691.sql new file mode 100644 index 0000000000..09ca4426ce --- /dev/null +++ b/migration/i5.1/postgresql/201804170900_IDEMPIERE-3691.sql @@ -0,0 +1,7 @@ +-- IDEMPIERE-3691 "Row" tooltip is not translated +-- Apr 17, 2018 9:04:04 AM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Row',0,0,'Y',TO_TIMESTAMP('2018-04-17 09:04:03','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2018-04-17 09:04:03','YYYY-MM-DD HH24:MI:SS'),0,200452,'Row','D','df5d9baf-0fd2-477c-aa27-da90069bbd07') +; + +SELECT register_migration_script('201804170900_IDEMPIERE-3691.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java index 39a8f79726..a31c5c69eb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java @@ -587,7 +587,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt row.setStyle("cursor:pointer"); row.addEventListener(Events.ON_CLICK, rowListener); row.addEventListener(Events.ON_OK, rowListener); - row.setTooltiptext("Row " + (rowIndex+1)); + row.setTooltiptext(Msg.getMsg(Env.getCtx(), "Row") + " " + (rowIndex+1)); if (isActive == null) { Object isActiveValue = gridTab.getValue(rowIndex, "IsActive"); From 75b817b0876977a8caaed655a4d58e71356558b9 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 17 Apr 2018 09:50:09 +0200 Subject: [PATCH 5/8] IDEMPIERE-3678 getAD_OrgBP_ID of I_C_BPartner returns string instead of number in DB that causes error in "Convert lead to bp" --- .../oracle/201804170941_IDEMPIERE-3678.sql | 107 ++++++++++++++++++ .../201804170941_IDEMPIERE-3678.sql | 104 +++++++++++++++++ .../src/org/compiere/model/MBPartner.java | 2 + 3 files changed, 213 insertions(+) create mode 100644 migration/i5.1/oracle/201804170941_IDEMPIERE-3678.sql create mode 100644 migration/i5.1/postgresql/201804170941_IDEMPIERE-3678.sql diff --git a/migration/i5.1/oracle/201804170941_IDEMPIERE-3678.sql b/migration/i5.1/oracle/201804170941_IDEMPIERE-3678.sql new file mode 100644 index 0000000000..3fd28b19ae --- /dev/null +++ b/migration/i5.1/oracle/201804170941_IDEMPIERE-3678.sql @@ -0,0 +1,107 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3678 +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=40, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62137 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62128 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62129 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62116 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62131 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62133 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62134 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62132 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62135 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62143 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62140 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62725 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62724 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=170, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62139 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=180, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62144 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=190, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62155 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62147 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=210, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62148 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=220, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62149 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=230, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62150 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=240, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62130 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204611 +; + +-- Apr 17, 2018 9:40:56 AM CEST +UPDATE AD_Field SET DisplayLogic='@C_BPartner_ID@!0', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsAllowCopy='N', IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:40:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62137 +; + +-- Apr 17, 2018 9:46:44 AM CEST +UPDATE AD_Process_Para SET MandatoryLogic='@CreateOpportunity@=Y',Updated=TO_DATE('2018-04-17 09:46:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53585 +; + +-- Apr 17, 2018 9:48:43 AM CEST +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@C_BPartner_ID@!0', IsToolbarButton=NULL,Updated=TO_DATE('2018-04-17 09:48:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62116 +; + +SELECT register_migration_script('201804170941_IDEMPIERE-3678.sql') FROM dual +; + diff --git a/migration/i5.1/postgresql/201804170941_IDEMPIERE-3678.sql b/migration/i5.1/postgresql/201804170941_IDEMPIERE-3678.sql new file mode 100644 index 0000000000..938182b6f4 --- /dev/null +++ b/migration/i5.1/postgresql/201804170941_IDEMPIERE-3678.sql @@ -0,0 +1,104 @@ +-- IDEMPIERE-3678 +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=40, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62137 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62128 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62129 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62116 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62131 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62133 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62134 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62132 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62135 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62143 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62140 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62725 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62724 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=170, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62139 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=180, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62144 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=190, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62155 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62147 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=210, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62148 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=220, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62149 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=230, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62150 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=240, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62130 +; + +-- Apr 17, 2018 9:39:44 AM CEST +UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:39:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204611 +; + +-- Apr 17, 2018 9:40:56 AM CEST +UPDATE AD_Field SET DisplayLogic='@C_BPartner_ID@!0', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsAllowCopy='N', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:40:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62137 +; + +-- Apr 17, 2018 9:46:44 AM CEST +UPDATE AD_Process_Para SET MandatoryLogic='@CreateOpportunity@=Y',Updated=TO_TIMESTAMP('2018-04-17 09:46:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53585 +; + +-- Apr 17, 2018 9:48:43 AM CEST +UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@C_BPartner_ID@!0', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-04-17 09:48:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=62116 +; + +SELECT register_migration_script('201804170941_IDEMPIERE-3678.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MBPartner.java b/org.adempiere.base/src/org/compiere/model/MBPartner.java index 4e41f09be8..9a9f7b2ffd 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartner.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartner.java @@ -65,6 +65,8 @@ public class MBPartner extends X_C_BPartner { template.set_ValueNoCheck ("C_BPartner_ID", new Integer(0)); template.set_ValueNoCheck ("C_BPartner_UU", (String)null); + template.setAD_OrgBP_ID(0); + template.setLogo_ID(0); template.setValue (""); template.setName (""); template.setName2 (null); From a9a32185173c503d9289ff07ffd26c5114f4ea59 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 17 Apr 2018 10:33:40 +0200 Subject: [PATCH 6/8] IDEMPIERE-3690 java.lang.NullPointerException when inactive al document status --- .../org/adempiere/webui/apps/graph/WDocumentStatusPanel.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WDocumentStatusPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WDocumentStatusPanel.java index a929057b48..e03f4a83ac 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WDocumentStatusPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WDocumentStatusPanel.java @@ -56,15 +56,13 @@ public class WDocumentStatusPanel extends Panel { /** * Get Panel if User has Document Status Indicators - * @return panel pr null + * @return panel */ public static WDocumentStatusPanel get() { int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx()); MDocumentStatus[] indicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(), AD_User_ID, AD_Role_ID); - if (indicators.length == 0) - return null; return new WDocumentStatusPanel(indicators); } From a7be63439a79b653dd3e125baa72afc60bba02b6 Mon Sep 17 00:00:00 2001 From: hieplq Date: Tue, 17 Apr 2018 14:50:34 +0200 Subject: [PATCH 7/8] IDEMPIERE-3512:csv import/export:resolve foreign should respect dynamic validate --- .../adempiere/impexp/GridTabCSVImporter.java | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) mode change 100644 => 100755 org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java old mode 100644 new mode 100755 index 524d44bd43..79e6bf0e81 --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java @@ -43,11 +43,13 @@ import org.adempiere.base.IGridTabImporter; import org.adempiere.exceptions.AdempiereException; import org.adempiere.util.IProcessUI; import org.adempiere.util.ProcessUtil; +import org.apache.commons.lang.StringUtils; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.model.GridWindow; import org.compiere.model.GridWindowVO; import org.compiere.model.MColumn; +import org.compiere.model.MField; import org.compiere.model.MLocation; import org.compiere.model.MProcess; import org.compiere.model.MQuery; @@ -962,7 +964,7 @@ public class GridTabCSVImporter implements IGridTabImporter if("AD_Ref_List".equals(foreignTable)) idS= resolveForeignList(column,foreignColumn,value,null); else - id = resolveForeign(foreignTable,foreignColumn,value,null); + id = resolveForeign(foreignTable,foreignColumn,value,field,null); if(idS == null && id < 0){ //it could be that record still doesn't exist if import mode is inserting or merging @@ -1025,7 +1027,7 @@ public class GridTabCSVImporter implements IGridTabImporter if(isForeing && !"(null)".equals(value)){ String foreignTable = columnName.substring(0,columnName.length()-3); - int id = resolveForeign(foreignTable,foreignColumn,value,null); + int id = resolveForeign(foreignTable,foreignColumn,value,field,null); if (id < 0) return new StringBuilder(Msg.getMsg(Env.getCtx(), id==-2?"ForeignMultipleResolved":"ForeignNotResolved" ,new Object[]{header.get(j),value})); } @@ -1075,11 +1077,11 @@ public class GridTabCSVImporter implements IGridTabImporter address = new MLocation (Env.getCtx(),C_Location_ID,trx.getTrxName()); } } - + GridField field = gridTab.getField(columnName); if(!"(null)".equals(value.toString().trim())){ if(isForeing) { String foreignTable = columnName.substring(0,columnName.length()-3); - setValue = resolveForeign(foreignTable,foreignColumn,value,trx); + setValue = resolveForeign(foreignTable,foreignColumn,value,field,trx); if("C_City".equals(foreignTable)) address.setCity(value.toString()); }else @@ -1125,7 +1127,7 @@ public class GridTabCSVImporter implements IGridTabImporter if ("AD_Ref_List".equals(foreignTable)) idS= resolveForeignList(column, foreignColumn, value,trx); else - id = resolveForeign(foreignTable,foreignColumn,value,trx); + id = resolveForeign(foreignTable,foreignColumn,value, field, trx); if(idS == null && id < 0) return Msg.getMsg(Env.getCtx(),id==-2?"ForeignMultipleResolved":"ForeignNotResolved",new Object[]{header.get(i),value}); @@ -1169,7 +1171,7 @@ public class GridTabCSVImporter implements IGridTabImporter isThereRow =true; } else { - int id = resolveForeign(foreignTable, foreignColumn, value,trx); + int id = resolveForeign(foreignTable, foreignColumn, value,field,trx); if (id < 0) return Msg.getMsg(Env.getCtx(),id==-2?"ForeignMultipleResolved":"ForeignNotResolved",new Object[]{header.get(i),value}); @@ -1276,8 +1278,9 @@ public class GridTabCSVImporter implements IGridTabImporter if(isForeing) foreignColumn = columnName.substring(columnName.indexOf("[")+1,columnName.indexOf("]")); - columnName = getColumnName(false,isForeing,true,columnName); - MColumn column = MColumn.get(Env.getCtx(),gridTab.getField(columnName).getAD_Column_ID()); + columnName = getColumnName(false,isForeing,true,columnName); + GridField field = gridTab.getField(columnName); + MColumn column = MColumn.get(Env.getCtx(),field.getAD_Column_ID()); if (isForeing){ String foreignTable = column.getReferenceTableName(); if ("AD_Ref_List".equals(foreignTable)) { @@ -1287,7 +1290,7 @@ public class GridTabCSVImporter implements IGridTabImporter setValue = idS; } else { - int id = resolveForeign(foreignTable, foreignColumn, setValue,trx); + int id = resolveForeign(foreignTable, foreignColumn, setValue, field, trx); if (id < 0) return Msg.getMsg(Env.getCtx(),id==-2?"ForeignMultipleResolved":"ForeignNotResolved",new Object[]{columnName,setValue}); @@ -1371,7 +1374,7 @@ public class GridTabCSVImporter implements IGridTabImporter String idS = resolveForeignList(column, foreignColumn, tmpValue,trx); setValue = idS; }else { - int id = resolveForeign(foreignTable, foreignColumn, tmpValue,trx); + int id = resolveForeign(foreignTable, foreignColumn, tmpValue,field,trx); setValue = id; } }else{ @@ -1400,7 +1403,8 @@ public class GridTabCSVImporter implements IGridTabImporter if(columnName!=null){ boolean isForeing = columnName.indexOf("[") > 0 && columnName.indexOf("]")>0; columnwithKey = getColumnName(false,isForeing,true,columnName); - MColumn column = MColumn.get(Env.getCtx(),gridTab.getField(columnwithKey).getAD_Column_ID()); + GridField field = gridTab.getField(columnwithKey); + MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID()); String foreignColumn = null; if(isForeing){ foreignColumn = columnName.substring(columnName.indexOf("[")+1,columnName.indexOf("]")); @@ -1409,7 +1413,7 @@ public class GridTabCSVImporter implements IGridTabImporter String idS = resolveForeignList(column,foreignColumn,value,trx); value = idS; }else { - int id = resolveForeign(foreignTable,foreignColumn,value,trx); + int id = resolveForeign(foreignTable,foreignColumn,value,field,trx); value = id; } } @@ -1462,7 +1466,7 @@ public class GridTabCSVImporter implements IGridTabImporter return idS; } - private int resolveForeign(String foreignTable, String foreignColumn, Object value,Trx trx) { + private int resolveForeign(String foreignTable, String foreignColumn, Object value, GridField field, Trx trx) { boolean systemAccess = false; if (!"AD_Client".equals(foreignTable)) { MTable ft = MTable.get(Env.getCtx(), foreignTable); @@ -1480,7 +1484,14 @@ public class GridTabCSVImporter implements IGridTabImporter StringBuilder postSelect = new StringBuilder(" FROM ") .append(foreignTable).append(" WHERE ") .append(foreignColumn).append("=? AND IsActive='Y' AND AD_Client_ID=?"); - + if (StringUtils.isNotBlank(field.getVO().ValidationCode)) { + String dynamicValid = Env.parseContext(Env.getCtx(), field.getWindowNo(), field.getGridTab().getTabNo(), field.getVO().ValidationCode, false); + if (StringUtils.isBlank(dynamicValid)) { + return 0;// it's parse error but simple consider like ForeignNotResolved + }else { + postSelect.append(" AND ").append(dynamicValid); + } + } StringBuilder selectCount = new StringBuilder("SELECT COUNT(*)").append(postSelect); StringBuilder selectId = new StringBuilder("SELECT ").append(foreignTable).append("_ID").append(postSelect); int count = DB.getSQLValueEx(trxName, selectCount.toString(), value, thisClientId); From 05dc56dc0eefe2a9d90ef4765a74aea285c9616c Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 17 Apr 2018 14:51:54 +0200 Subject: [PATCH 8/8] IDEMPIERE-3512 csv import/export:resolve foreign should respect dynamic validate / peer review - add also reference validation --- .../adempiere/impexp/GridTabCSVImporter.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) mode change 100755 => 100644 org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java old mode 100755 new mode 100644 index 79e6bf0e81..811669430e --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java @@ -43,19 +43,19 @@ import org.adempiere.base.IGridTabImporter; import org.adempiere.exceptions.AdempiereException; import org.adempiere.util.IProcessUI; import org.adempiere.util.ProcessUtil; -import org.apache.commons.lang.StringUtils; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.model.GridWindow; import org.compiere.model.GridWindowVO; import org.compiere.model.MColumn; -import org.compiere.model.MField; import org.compiere.model.MLocation; import org.compiere.model.MProcess; import org.compiere.model.MQuery; import org.compiere.model.MRefList; +import org.compiere.model.MRefTable; import org.compiere.model.MTable; import org.compiere.model.PO; +import org.compiere.model.Query; import org.compiere.process.ProcessInfo; import org.compiere.tools.FileUtil; import org.compiere.util.CLogger; @@ -65,6 +65,7 @@ import org.compiere.util.Env; import org.compiere.util.Language; import org.compiere.util.Msg; import org.compiere.util.Trx; +import org.compiere.util.Util; import org.compiere.util.ValueNamePair; import org.compiere.wf.MWFProcess; import org.supercsv.cellprocessor.Optional; @@ -1484,12 +1485,28 @@ public class GridTabCSVImporter implements IGridTabImporter StringBuilder postSelect = new StringBuilder(" FROM ") .append(foreignTable).append(" WHERE ") .append(foreignColumn).append("=? AND IsActive='Y' AND AD_Client_ID=?"); - if (StringUtils.isNotBlank(field.getVO().ValidationCode)) { + if (!Util.isEmpty(field.getVO().ValidationCode)) { String dynamicValid = Env.parseContext(Env.getCtx(), field.getWindowNo(), field.getGridTab().getTabNo(), field.getVO().ValidationCode, false); - if (StringUtils.isBlank(dynamicValid)) { + if (Util.isEmpty(dynamicValid)) { return 0;// it's parse error but simple consider like ForeignNotResolved }else { - postSelect.append(" AND ").append(dynamicValid); + postSelect.append(" AND (").append(dynamicValid).append(")"); + } + } + int ref = field.getVO().displayType; + int refval = field.getVO().AD_Reference_Value_ID; + if (refval > 0 && (ref == DisplayType.Table || ref == DisplayType.Search)) { + final MRefTable refTable = new Query(Env.getCtx(), MRefTable.Table_Name, "AD_Reference_ID=?", trxName) + .setParameters(refval) + .firstOnly(); + String whereClause = refTable.getWhereClause(); + if (!Util.isEmpty(whereClause)) { + String dynamicValid = Env.parseContext(Env.getCtx(), field.getWindowNo(), field.getGridTab().getTabNo(), whereClause, false); + if (Util.isEmpty(dynamicValid)) { + return 0;// it's parse error but simple consider like ForeignNotResolved + }else { + postSelect.append(" AND (").append(dynamicValid).append(")"); + } } } StringBuilder selectCount = new StringBuilder("SELECT COUNT(*)").append(postSelect);