From a9b9b143bcabc8cebe5c611a34cbe30ebcaa48fd Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 11 Aug 2016 14:22:35 +0200 Subject: [PATCH 01/21] IDEMPIERE-3156 SubAcct not working on Account Combination Dialog / make it work also in Product window --- org.adempiere.base/src/org/compiere/util/Env.java | 9 +++++++++ .../src/org/adempiere/webui/window/WAccountDialog.java | 2 ++ 2 files changed, 11 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index 3df4e16c3c..c0be165330 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -390,6 +390,15 @@ public final class Env ctx.setProperty(WindowNo+"|"+context, String.valueOf(value)); } // setContext + public static void setContext (Properties ctx, int WindowNo, int TabNo, String context, int value) + { + if (ctx == null || context == null) + return; + if (log.isLoggable(Level.FINER)) log.finer("Context("+WindowNo+") " + context + "==" + value); + // + ctx.setProperty(WindowNo+"|"+TabNo+"|"+context, String.valueOf(value)); + } // setContext + /** * Set Context for Window to Y/N Value * @param ctx context diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java index 4ead03f260..de5bf7d759 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java @@ -1212,7 +1212,9 @@ public final class WAccountDialog extends Window Object newValue = evt.getNewValue(); if (newValue instanceof Integer) { Env.setContext(Env.getCtx(), m_WindowNo, "Account_ID", ((Integer)newValue).intValue()); + Env.setContext(Env.getCtx(), m_WindowNo, 0, "Account_ID", ((Integer)newValue).intValue()); if (f_SubAcct_ID != null) { + f_SubAcct_ID.setValue(null); f_SubAcct_ID.dynamicDisplay(); } } From dc82ae4f7829eb4f0a08ce8b2f899db4107da2d3 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 11 Aug 2016 21:08:29 +0200 Subject: [PATCH 02/21] IDEMPIERE-3156 SubAcct not working on Account Combination Dialog / refresh subacct lookup on initial load --- .../src/org/adempiere/webui/window/WAccountDialog.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java index de5bf7d759..4caad9331b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java @@ -471,8 +471,16 @@ public final class WAccountDialog extends Window statusBar.setStatusDB(""); // Initial value - if (m_mAccount.C_ValidCombination_ID != 0) + if (m_mAccount.C_ValidCombination_ID != 0) { m_mTab.navigate(0); + if (f_Account_ID.getValue() instanceof Integer) { + Env.setContext(Env.getCtx(), m_WindowNo, "Account_ID", (Integer)f_Account_ID.getValue()); + Env.setContext(Env.getCtx(), m_WindowNo, 0, "Account_ID", (Integer)f_Account_ID.getValue()); + if (f_SubAcct_ID != null) { + f_SubAcct_ID.dynamicDisplay(); + } + } + } log.config("fini"); return true; From c6ac14ef6001527772d5e696c0348c7dba5c9d88 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 24 Aug 2016 12:24:36 +0200 Subject: [PATCH 03/21] IDEMPIERE-3163 Overwritten Dynamic Validation can become invisible and used by system --- org.adempiere.base/src/org/compiere/model/MField.java | 5 +++++ org.adempiere.base/src/org/compiere/model/MUserDefField.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/model/MField.java b/org.adempiere.base/src/org/compiere/model/MField.java index 1f2ae8964d..cea2cdf80c 100644 --- a/org.adempiere.base/src/org/compiere/model/MField.java +++ b/org.adempiere.base/src/org/compiere/model/MField.java @@ -144,6 +144,11 @@ public class MField extends X_AD_Field if (getAD_Column().getColumnName().equals("AD_Org_ID")) // AD_Org_ID can be copied setIsAllowCopy("Y"); } + if (getAD_Reference_ID() <= 0) { + setAD_Reference_Value_ID(0); + setAD_Val_Rule_ID(0); + setIsToolbarButton(null); + } return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/model/MUserDefField.java b/org.adempiere.base/src/org/compiere/model/MUserDefField.java index 782f8e26e7..4013b68e9a 100644 --- a/org.adempiere.base/src/org/compiere/model/MUserDefField.java +++ b/org.adempiere.base/src/org/compiere/model/MUserDefField.java @@ -134,6 +134,11 @@ public class MUserDefField extends X_AD_UserDef_Field return false; } } + if (getAD_Reference_ID() <= 0) { + setAD_Reference_Value_ID(0); + setAD_Val_Rule_ID(0); + setIsToolbarButton(null); + } return true; } From 9dca8269bbc3a26ac99f5f43d4959b90d0786043 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 24 Aug 2016 12:38:57 +0200 Subject: [PATCH 04/21] IDEMPIERE-3165 Calendar create period use wrong org --- org.adempiere.base/src/org/compiere/model/MPeriodControl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/org.adempiere.base/src/org/compiere/model/MPeriodControl.java b/org.adempiere.base/src/org/compiere/model/MPeriodControl.java index c24d79a8c7..0539d2aaa9 100644 --- a/org.adempiere.base/src/org/compiere/model/MPeriodControl.java +++ b/org.adempiere.base/src/org/compiere/model/MPeriodControl.java @@ -71,6 +71,7 @@ public class MPeriodControl extends X_C_PeriodControl { this (period.getCtx(), period.getAD_Client_ID(), period.getC_Period_ID(), DocBaseType, period.get_TrxName()); + setClientOrg(period); } // MPeriodControl /** From eb581aa70ea8498e9199fbc34115c18b96138cd1 Mon Sep 17 00:00:00 2001 From: hieplq Date: Sat, 20 Aug 2016 01:16:00 +0700 Subject: [PATCH 05/21] IDEMPIERE-1138:Broadcast Message Problems NPE when close message dialog --- .../src/org/adempiere/webui/panel/BroadcastMessageWindow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java index 0c945b5f0b..24a50569df 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java @@ -53,7 +53,7 @@ import org.zkoss.zul.South; */ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup,EventListener{ /** - * + * */ private static final long serialVersionUID = 1849434312706721390L; @@ -318,7 +318,7 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup public MNote getMNote(MBroadcastMessage mbMessage) { MNote note =null; if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){ - String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ? AND AD_Client_ID = ?"; + String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ? AND AD_Client_ID in (?, 0)"; PreparedStatement pstmt = null; ResultSet rs=null; try { From 5cfb8bce61648b32b4db136c6f40ed1e8f73a0b9 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 24 Aug 2016 15:03:55 +0200 Subject: [PATCH 06/21] IDEMPIERE-3159 Importing Orders / Invoices implicitly creating BPs fail to see BPs already created in the same import process / integrate patch contributed by Daniel Haag (dhdx) --- .../org/compiere/process/ImportInvoice.java | 2 +- .../src/org/compiere/process/ImportOrder.java | 2 +- .../src/org/compiere/model/MBPartner.java | 32 ++++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java b/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java index 081b246a79..137b6fc424 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java @@ -525,7 +525,7 @@ public class ImportInvoice extends SvrProcess imp.setName (imp.getBPartnerValue ()); } // BPartner - MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue()); + MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue(), get_TrxName()); if (bp == null) { bp = new MBPartner (getCtx (), -1, get_TrxName()); diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java b/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java index bcf3992bb2..4f1c6347c2 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java @@ -525,7 +525,7 @@ public class ImportOrder extends SvrProcess imp.setName (imp.getBPartnerValue ()); } // BPartner - MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue()); + MBPartner bp = MBPartner.get (getCtx(), imp.getBPartnerValue(), get_TrxName()); if (bp == null) { bp = new MBPartner (getCtx (), -1, get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/MBPartner.java b/org.adempiere.base/src/org/compiere/model/MBPartner.java index 28adf4c002..c91dee9980 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartner.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartner.java @@ -47,7 +47,7 @@ public class MBPartner extends X_C_BPartner /** * */ - private static final long serialVersionUID = -5503105554864289337L; + private static final long serialVersionUID = -803727877324075871L; /** * Get Empty Template Business Partner @@ -110,12 +110,23 @@ public class MBPartner extends X_C_BPartner * @param Value value * @return BPartner or null */ - public static MBPartner get (Properties ctx, String Value) + public static MBPartner get (Properties ctx, String Value) { + return get(ctx,Value,null); + } + + /** + * Get BPartner with Value in a transaction + * @param ctx context + * @param Value value + * @param trxName transaction + * @return BPartner or null + */ + public static MBPartner get (Properties ctx, String Value, String trxName) { if (Value == null || Value.length() == 0) return null; final String whereClause = "Value=? AND AD_Client_ID=?"; - MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, null) + MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, trxName) .setParameters(Value,Env.getAD_Client_ID(ctx)) .firstOnly(); return retValue; @@ -128,9 +139,22 @@ public class MBPartner extends X_C_BPartner * @return BPartner or null */ public static MBPartner get (Properties ctx, int C_BPartner_ID) + { + return get(ctx,C_BPartner_ID,null); + } + + + /** + * Get BPartner with Value in a transaction + * @param ctx context + * @param Value value + * @param trxName transaction + * @return BPartner or null + */ + public static MBPartner get (Properties ctx, int C_BPartner_ID, String trxName) { final String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?"; - MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause,null) + MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause,trxName) .setParameters(C_BPartner_ID,Env.getAD_Client_ID(ctx)) .firstOnly(); return retValue; From eb6c1f43473e533d6e59cc9e05d0dd72f8e01291 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 24 Aug 2016 15:11:22 +0200 Subject: [PATCH 07/21] IDEMPIERE-3158 When we copy a bank account, the field Current Balance is copied too / integrate patch contributed by Matheus Eduardo Marcelino (MatheusMarcelino) --- .../i3.1/oracle/20160815103455_IDEMPIERE-3158.sql | 10 ++++++++++ .../i3.1/postgresql/20160815103455_IDEMPIERE-3158.sql | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 migration/i3.1/oracle/20160815103455_IDEMPIERE-3158.sql create mode 100644 migration/i3.1/postgresql/20160815103455_IDEMPIERE-3158.sql diff --git a/migration/i3.1/oracle/20160815103455_IDEMPIERE-3158.sql b/migration/i3.1/oracle/20160815103455_IDEMPIERE-3158.sql new file mode 100644 index 0000000000..c7e3dac0a2 --- /dev/null +++ b/migration/i3.1/oracle/20160815103455_IDEMPIERE-3158.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- Aug 15, 2016 10:12:48 AM BRT +UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_DATE('2016-08-15 10:12:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3075 +; + +SELECT register_migration_script('20160815103455_IDEMPIERE-3158.sql') FROM dual +; diff --git a/migration/i3.1/postgresql/20160815103455_IDEMPIERE-3158.sql b/migration/i3.1/postgresql/20160815103455_IDEMPIERE-3158.sql new file mode 100644 index 0000000000..9e128deeb5 --- /dev/null +++ b/migration/i3.1/postgresql/20160815103455_IDEMPIERE-3158.sql @@ -0,0 +1,7 @@ +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- Aug 15, 2016 10:12:48 AM BRT +UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_TIMESTAMP('2016-08-15 10:12:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3075 +; + +SELECT register_migration_script('20160815103455_IDEMPIERE-3158.sql') FROM dual +; From 0d78b00ce2ba5b69d54bf79f7584b533231c4e49 Mon Sep 17 00:00:00 2001 From: hieplq Date: Wed, 17 Aug 2016 23:53:56 +0700 Subject: [PATCH 08/21] IDEMPIERE-3162:infoPanel:postgresql need trx to use cursor based resultset --- org.adempiere.base/src/org/compiere/model/GridTable.java | 1 + .../WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index f4be409bd3..f9c094ccb2 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -3543,6 +3543,7 @@ public class GridTable extends AbstractTableModel private void openResultSet() { //postgresql need trx to use cursor based resultset + //https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor String trxName = m_virtual ? Trx.createTrxName("Loader") : null; trx = trxName != null ? Trx.get(trxName, true) : null; // open Statement (closed by Loader.close) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 1c6f9932aa..679dc6475b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -840,9 +840,13 @@ public abstract class InfoPanel extends Window implements EventListener, isHasNextPage = false; if (log.isLoggable(Level.FINER)) log.finer(dataSql); + Trx trx = null; try { - m_pstmt = DB.prepareStatement(dataSql, null); + //https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor + String trxName = Trx.createTrxName("InfoPanelLoad:"); + trx = Trx.get(trxName, true); + m_pstmt = DB.prepareStatement(dataSql, trxName); setParameters (m_pstmt, false); // no count if (log.isLoggable(Level.FINE)) log.fine("Start query - " + (System.currentTimeMillis()-startTime) + "ms"); @@ -889,6 +893,7 @@ public abstract class InfoPanel extends Window implements EventListener, finally { DB.close(m_rs, m_pstmt); + trx.close(); } if (end > cacheEnd || end <= 0) From e6bc9b7cf2005d5455da9d50f6d42f0c658a64bb Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 1 Sep 2016 15:29:36 +0200 Subject: [PATCH 09/21] IDEMPIERE-3146 CSV Import issues with resolveForeign when key is duplicated on foreign table / restore previous behavior to resolve foreign, first check on client then on system (not at the same time) --- .../adempiere/impexp/GridTabCSVImporter.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java index e392f20682..f62dd73b17 100644 --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java @@ -1464,30 +1464,33 @@ public class GridTabCSVImporter implements IGridTabImporter systemAccess = true; } } + int thisClientId = Env.getAD_Client_ID(Env.getCtx()); String trxName = (trx!=null?trx.getTrxName():null); StringBuilder postSelect = new StringBuilder(" FROM ") .append(foreignTable).append(" WHERE ") - .append(foreignColumn).append("=? AND IsActive='Y' AND AD_Client_ID"); - if (systemAccess) { - postSelect.append(" IN (0,?)"); - } else { - postSelect.append("=?"); - } + .append(foreignColumn).append("=? AND IsActive='Y' AND AD_Client_ID=?"); StringBuilder selectCount = new StringBuilder("SELECT COUNT(*)").append(postSelect); - int count = DB.getSQLValueEx(trxName, selectCount.toString(), value, Env.getAD_Client_ID(Env.getCtx())); + StringBuilder selectId = new StringBuilder("SELECT ").append(foreignTable).append("_ID").append(postSelect); + int count = DB.getSQLValueEx(trxName, selectCount.toString(), value, thisClientId); if (count == 1) { // single value found, OK - StringBuilder selectId = new StringBuilder("SELECT ").append(foreignTable).append("_ID").append(postSelect); - id = DB.getSQLValueEx(trxName, selectId.toString(), value, Env.getAD_Client_ID(Env.getCtx())); + return DB.getSQLValueEx(trxName, selectId.toString(), value, thisClientId); } else if (count > 1) { // multiple values found, error ForeignMultipleResolved - id = -2; + return -2; } else if (count == 0) { // no values found, error ForeignNotResolved - id = -3; + if (systemAccess && thisClientId != 0) { + // not found in client, try with System + count = DB.getSQLValueEx(trxName, selectCount.toString(), value, 0 /* System */); + if (count == 1) { // single value found, OK + return DB.getSQLValueEx(trxName, selectId.toString(), value, 0 /* System */); + } else if (count > 1) { // multiple values found, error ForeignMultipleResolved + return -2; + } + } } - - return id; + return -3; // no values found, error ForeignNotResolved } //Copy from GridTable From 8f01084f7c286375b279a653258474fc4edd97d4 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 3 Sep 2016 15:42:01 +0200 Subject: [PATCH 10/21] IDEMPIERE-3171 Can't add record on POS Terminal / IDEMPIERE-170 --- .../oracle/201609031532_IDEMPIERE-3171.sql | 27 +++++++++++++++++++ .../201609031532_IDEMPIERE-3171.sql | 24 +++++++++++++++++ .../src/org/compiere/model/MPOS.java | 10 ++++--- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 migration/i3.1/oracle/201609031532_IDEMPIERE-3171.sql create mode 100644 migration/i3.1/postgresql/201609031532_IDEMPIERE-3171.sql diff --git a/migration/i3.1/oracle/201609031532_IDEMPIERE-3171.sql b/migration/i3.1/oracle/201609031532_IDEMPIERE-3171.sql new file mode 100644 index 0000000000..a2f11995c1 --- /dev/null +++ b/migration/i3.1/oracle/201609031532_IDEMPIERE-3171.sql @@ -0,0 +1,27 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3171 Can't add record on POS Terminal, IDEMPIERE-170 +-- Sep 3, 2016 2:31:03 PM GMT+01:00 +UPDATE AD_Field SET IsDisplayed='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsDisplayedGrid='N', IsToolbarButton=NULL,Updated=TO_DATE('2016-09-03 14:31:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802 +; + +-- Sep 3, 2016 2:31:33 PM GMT+01:00 +UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2016-09-03 14:31:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12750 +; + +-- Sep 3, 2016 2:31:40 PM GMT+01:00 +UPDATE AD_Field SET DefaultValue='-1', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2016-09-03 14:31:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802 +; + +-- Sep 3, 2016 2:39:09 PM GMT+01:00 +ALTER TABLE C_POS MODIFY C_CashBook_ID NUMBER(10) DEFAULT NULL +; + +-- Sep 3, 2016 2:39:09 PM GMT+01:00 +ALTER TABLE C_POS MODIFY C_CashBook_ID NULL +; + +SELECT register_migration_script('201609031532_IDEMPIERE-3171.sql') FROM dual +; + diff --git a/migration/i3.1/postgresql/201609031532_IDEMPIERE-3171.sql b/migration/i3.1/postgresql/201609031532_IDEMPIERE-3171.sql new file mode 100644 index 0000000000..bfda324d55 --- /dev/null +++ b/migration/i3.1/postgresql/201609031532_IDEMPIERE-3171.sql @@ -0,0 +1,24 @@ +-- IDEMPIERE-3171 Can't add record on POS Terminal, IDEMPIERE-170 +-- Sep 3, 2016 2:31:03 PM GMT+01:00 +UPDATE AD_Field SET IsDisplayed='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsDisplayedGrid='N', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2016-09-03 14:31:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802 +; + +-- Sep 3, 2016 2:31:33 PM GMT+01:00 +UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2016-09-03 14:31:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=12750 +; + +-- Sep 3, 2016 2:31:40 PM GMT+01:00 +UPDATE AD_Field SET DefaultValue='-1', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2016-09-03 14:31:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10802 +; + +-- Sep 3, 2016 2:39:09 PM GMT+01:00 +INSERT INTO t_alter_column values('c_pos','C_CashBook_ID','NUMERIC(10)',null,'NULL') +; + +-- Sep 3, 2016 2:39:09 PM GMT+01:00 +INSERT INTO t_alter_column values('c_pos','C_CashBook_ID',null,'NULL',null) +; + +SELECT register_migration_script('201609031532_IDEMPIERE-3171.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MPOS.java b/org.adempiere.base/src/org/compiere/model/MPOS.java index 7e74c55b7e..cd8bb144c3 100644 --- a/org.adempiere.base/src/org/compiere/model/MPOS.java +++ b/org.adempiere.base/src/org/compiere/model/MPOS.java @@ -120,15 +120,17 @@ public class MPOS extends X_C_POS protected boolean beforeSave (boolean newRecord) { // Org Consistency - if (newRecord - || is_ValueChanged("C_CashBook_ID") || is_ValueChanged("M_Warehouse_ID")) + if (newRecord || is_ValueChanged("C_BankAccount_ID")) { - MCashBook cb = MCashBook.get(getCtx(), getC_CashBook_ID(), get_TrxName()); + MBankAccount cb = MBankAccount.get(getCtx(), getC_BankAccount_ID()); if (cb.getAD_Org_ID() != getAD_Org_ID()) { - log.saveError("Error", Msg.parseTranslation(getCtx(), "@AD_Org_ID@: @C_CashBook_ID@")); + log.saveError("Error", Msg.parseTranslation(getCtx(), "@AD_Org_ID@: @C_BankAccount_ID@")); return false; } + } + if (newRecord || is_ValueChanged("M_Warehouse_ID")) + { MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID(), get_TrxName()); if (wh.getAD_Org_ID() != getAD_Org_ID()) { From e3c42f607864851a4c08ec0158b984be22e94205 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 3 Sep 2016 15:47:15 +0200 Subject: [PATCH 11/21] IDEMPIERE-3173 Columns that must not be copied C_BPartner.ActualLifeTimeValue --- migration/i3.1/oracle/201609031546_IDEMPIERE-3173.sql | 11 +++++++++++ .../i3.1/postgresql/201609031546_IDEMPIERE-3173.sql | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 migration/i3.1/oracle/201609031546_IDEMPIERE-3173.sql create mode 100644 migration/i3.1/postgresql/201609031546_IDEMPIERE-3173.sql diff --git a/migration/i3.1/oracle/201609031546_IDEMPIERE-3173.sql b/migration/i3.1/oracle/201609031546_IDEMPIERE-3173.sql new file mode 100644 index 0000000000..db88ebd7d6 --- /dev/null +++ b/migration/i3.1/oracle/201609031546_IDEMPIERE-3173.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3173 Columns that must not be copied +-- Sep 3, 2016 2:45:57 PM GMT+01:00 +UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_DATE('2016-09-03 14:45:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2925 +; + +SELECT register_migration_script('201609031546_IDEMPIERE-3173.sql') FROM dual +; + diff --git a/migration/i3.1/postgresql/201609031546_IDEMPIERE-3173.sql b/migration/i3.1/postgresql/201609031546_IDEMPIERE-3173.sql new file mode 100644 index 0000000000..d4d68855cb --- /dev/null +++ b/migration/i3.1/postgresql/201609031546_IDEMPIERE-3173.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-3173 Columns that must not be copied +-- Sep 3, 2016 2:45:57 PM GMT+01:00 +UPDATE AD_Column SET IsAllowCopy='N',Updated=TO_TIMESTAMP('2016-09-03 14:45:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2925 +; + +SELECT register_migration_script('201609031546_IDEMPIERE-3173.sql') FROM dual +; + From 2c4b9163ae52401d72414645876c9d4a4737e193 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 3 Sep 2016 16:17:23 +0200 Subject: [PATCH 12/21] IDEMPIERE-2676 Incorrect context variables - onNavigate Callout / make on navigate callout read only --- .../oracle/201609031608_IDEMPIERE-2676.sql | 15 ++++++++++++ .../201609031608_IDEMPIERE-2676.sql | 12 ++++++++++ .../src/org/compiere/model/CalloutOrder.java | 23 +++++++++++++++---- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 migration/i3.1/oracle/201609031608_IDEMPIERE-2676.sql create mode 100644 migration/i3.1/postgresql/201609031608_IDEMPIERE-2676.sql diff --git a/migration/i3.1/oracle/201609031608_IDEMPIERE-2676.sql b/migration/i3.1/oracle/201609031608_IDEMPIERE-2676.sql new file mode 100644 index 0000000000..6a12179311 --- /dev/null +++ b/migration/i3.1/oracle/201609031608_IDEMPIERE-2676.sql @@ -0,0 +1,15 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-2676 Incorrect context variables - onNavigate Callout +-- Sep 3, 2016 3:07:56 PM GMT+01:00 +UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_DATE('2016-09-03 15:07:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2161 +; + +-- Sep 3, 2016 3:08:09 PM GMT+01:00 +UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_DATE('2016-09-03 15:08:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3484 +; + +SELECT register_migration_script('201609031608_IDEMPIERE-2676.sql') FROM dual +; + diff --git a/migration/i3.1/postgresql/201609031608_IDEMPIERE-2676.sql b/migration/i3.1/postgresql/201609031608_IDEMPIERE-2676.sql new file mode 100644 index 0000000000..b9666ef6cb --- /dev/null +++ b/migration/i3.1/postgresql/201609031608_IDEMPIERE-2676.sql @@ -0,0 +1,12 @@ +-- IDEMPIERE-2676 Incorrect context variables - onNavigate Callout +-- Sep 3, 2016 3:07:56 PM GMT+01:00 +UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_TIMESTAMP('2016-09-03 15:07:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2161 +; + +-- Sep 3, 2016 3:08:09 PM GMT+01:00 +UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.priceListReadOnly', IsUpdateable='N',Updated=TO_TIMESTAMP('2016-09-03 15:08:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3484 +; + +SELECT register_migration_script('201609031608_IDEMPIERE-2676.sql') FROM dual +; + diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 98303c4a85..670d252e26 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -661,9 +661,10 @@ public class CalloutOrder extends CalloutEngine * @param mTab Grid Tab * @param mField Grid Field * @param value New Value + * @param readonly Read Only - do not set tab fields, just context * @return null or error message */ - public String priceList (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) + public String priceListFill (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, boolean readonly) { Integer M_PriceList_ID = (Integer) mTab.getValue("M_PriceList_ID"); if (M_PriceList_ID == null || M_PriceList_ID.intValue()== 0) @@ -695,12 +696,16 @@ public class CalloutOrder extends CalloutEngine if (rs.next()) { // Tax Included - mTab.setValue("IsTaxIncluded", new Boolean("Y".equals(rs.getString(1)))); + if (!readonly) { + mTab.setValue("IsTaxIncluded", new Boolean("Y".equals(rs.getString(1)))); + } // Price Limit Enforce Env.setContext(ctx, WindowNo, "EnforcePriceLimit", rs.getString(2)); // Currency - Integer ii = new Integer(rs.getInt(3)); - mTab.setValue("C_Currency_ID", ii); + if (!readonly) { + Integer ii = new Integer(rs.getInt(3)); + mTab.setValue("C_Currency_ID", ii); + } // PriceList Version Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", rs.getInt(5)); } @@ -718,8 +723,18 @@ public class CalloutOrder extends CalloutEngine if (steps) log.warning("fini"); return ""; + } // priceListFill + + public String priceList (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) + { + return priceListFill (ctx, WindowNo, mTab, mField, value, false); } // priceList + /* IDEMPIERE-2676 - this is same callout priceList but not setting any variable, just reading and setting context, called on navigate */ + public String priceListReadOnly (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) + { + return priceListFill (ctx, WindowNo, mTab, mField, value, true); + } // priceListReadOnly /** * Set Payment Term. From 70699cf4c38dbd791dacba0a4c628d03892cc814 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sat, 3 Sep 2016 17:16:31 +0200 Subject: [PATCH 13/21] IDEMPIERE-3118 1005938 Create new feature to scan and store files on tabs. Hide cancel button after user click on the capture image icon. Disable dialog during save. --- .../adempiere/webui/window/WImageDialog.java | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java index b425a3f012..d226d40072 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java @@ -200,6 +200,7 @@ public class WImageDialog extends Window implements EventListener confirmPanel.addActionListener(Events.ON_CLICK, this); addEventListener(Events.ON_UPLOAD, this); + addEventListener("onSave", this); } // init public void onEvent(Event e) throws Exception { @@ -210,19 +211,8 @@ public class WImageDialog extends Window implements EventListener } else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) { - if (image.getContent() != null) - { - if (!Util.isEmpty(fileNameTextbox.getValue())) - m_mImage.setName(fileNameTextbox.getValue()); - m_mImage.saveEx(); - } - else if (m_mImage != null && m_mImage.getAD_Image_ID() > 0) - { - m_mImage.setBinaryData(null); - m_mImage.setName("-"); - m_mImage.saveEx(); - } - detach(); + Clients.showBusy(this, Msg.getMsg(Env.getCtx(), "Processing")); + Events.echoEvent("onSave", this, null); } else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) { @@ -239,10 +229,12 @@ public class WImageDialog extends Window implements EventListener { captureDiv.setVisible(true); cancelCaptureButton.setVisible(true); + cancelCaptureButton.setEnabled(true); mainLayout.setVisible(false); String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');"; + script = script + "var cancelBtn=zk.Widget.$('#"+cancelCaptureButton.getUuid()+"');"; script = script + "jq(wgt).photobooth(); "; - script = script + "jq(wgt).bind( 'image', function( event, dataUrl ){ zAu.send(new zk.Event(wgt, 'onCaptureImage', dataUrl, {toServer:true})); });"; + script = script + "jq(wgt).bind( 'image', function( event, dataUrl ){ cancelBtn.setVisible(false);zAu.send(new zk.Event(wgt, 'onCaptureImage', dataUrl, {toServer:true})); });"; Clients.evalJavaScript(script); } else if (e.getName().equals("onCaptureImage")) @@ -278,6 +270,30 @@ public class WImageDialog extends Window implements EventListener script = script + "jq(wgt).data( 'photobooth').destroy(); "; Clients.evalJavaScript(script); } + else if (e.getName().equals("onSave")) + { + try { + onSave(); + } finally { + Clients.clearBusy(this); + } + } + } + + private void onSave() { + if (image.getContent() != null) + { + if (!Util.isEmpty(fileNameTextbox.getValue())) + m_mImage.setName(fileNameTextbox.getValue()); + m_mImage.saveEx(); + } + else if (m_mImage != null && m_mImage.getAD_Image_ID() > 0) + { + m_mImage.setBinaryData(null); + m_mImage.setName("-"); + m_mImage.saveEx(); + } + detach(); } /** From 1ebbb7b14e41072cd5cee8208176774af8eea330 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sat, 3 Sep 2016 17:22:48 +0200 Subject: [PATCH 14/21] IDEMPIERE-3174 1005975 display logic is not working when using Null as '' --- org.adempiere.base/src/org/compiere/util/Evaluator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/util/Evaluator.java b/org.adempiere.base/src/org/compiere/util/Evaluator.java index 42b31d1d70..104a863fe6 100644 --- a/org.adempiere.base/src/org/compiere/util/Evaluator.java +++ b/org.adempiere.base/src/org/compiere/util/Evaluator.java @@ -194,9 +194,9 @@ public class Evaluator secondEval = secondEval.replace('\'', ' ').replace('"', ' ').trim(); // strip ' and " // Handling of ID compare (null => 0) - if (first.indexOf("_ID") != -1 && firstEval.length() == 0) + if (first.trim().endsWith("_ID") && firstEval.length() == 0) firstEval = "0"; - if (second.indexOf("_ID") != -1 && secondEval.length() == 0) + if (second.trim().endsWith("_ID") && secondEval.length() == 0) secondEval = "0"; // Logical Comparison From 3c4b8997528595f0a8163c4982365f99dc3309ba Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 3 Sep 2016 17:29:17 +0200 Subject: [PATCH 15/21] IDEMPIERE-3175 Found 2pack problems when UUID is filled with external values --- .../src/org/adempiere/pipo2/AbstractElementHandler.java | 4 ++-- org.adempiere.pipo/src/org/adempiere/pipo2/POFinder.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java b/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java index 246975a92b..adaba59b51 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java @@ -489,7 +489,7 @@ public abstract class AbstractElementHandler implements ElementHandler { if (element.properties.containsKey(uuidColumn)) { uuid = element.properties.get(uuidColumn).contents.toString(); } - return (uuid != null && uuid.trim().length() == 36); + return (uuid != null && uuid.trim().length() <= 36); } protected String getUUIDKey(PIPOContext ctx, Element element) { @@ -497,7 +497,7 @@ public abstract class AbstractElementHandler implements ElementHandler { String uuidColumn = PO.getUUIDColumnName(tableName); if (element.properties.containsKey(uuidColumn)) { String uuid = element.properties.get(uuidColumn).contents.toString(); - if (uuid != null && uuid.trim().length() == 36) + if (uuid != null && uuid.trim().length() <= 36) return uuid.trim(); } return null; diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/POFinder.java b/org.adempiere.pipo/src/org/adempiere/pipo2/POFinder.java index a1d7e52a3e..9827ef1ef4 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/POFinder.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/POFinder.java @@ -82,7 +82,7 @@ public class POFinder { String idColumn = tableName + "_ID"; if (element.properties.containsKey(uuidColumn)) { String uuid = element.properties.get(uuidColumn).contents.toString(); - if (uuid != null && uuid.trim().length() == 36) { + if (uuid != null && uuid.trim().length() <= 36) { uuid = uuid.trim(); String targetUUID = Env.getAD_Client_ID(ctx.ctx) > 0 ? getTargetUUID(ctx.ctx, tableName, uuid, ctx.trx.getTrxName()) : uuid; Query query = new Query(ctx.ctx, tableName, uuidColumn+"=?", getTrxName(ctx)); From 2074c9622d1fc43f6256fdd1a5a4d183e6414fc9 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sat, 3 Sep 2016 17:34:51 +0200 Subject: [PATCH 16/21] IDEMPIERE-3176 1006115 Bug when adding ASI product line on Physical Inventory window. --- .../org/compiere/model/CalloutInventory.java | 11 +-- .../process/InventoryCountUpdate.java | 73 +------------------ 2 files changed, 5 insertions(+), 79 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java index 043bab2116..8876280d36 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInventory.java @@ -160,14 +160,10 @@ public class CalloutInventory extends CalloutEngine private BigDecimal setQtyBook (int M_AttributeSetInstance_ID, int M_Product_ID, int M_Locator_ID) throws Exception { // Set QtyBook from first storage location BigDecimal bd = null; - String sql = "SELECT QtyOnHand FROM M_StorageOnHand " + String sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand " + "WHERE M_Product_ID=?" // 1 + " AND M_Locator_ID=?" // 2 - + " AND M_AttributeSetInstance_ID=?"; - if (M_AttributeSetInstance_ID == 0) - sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand " - + "WHERE M_Product_ID=?" // 1 - + " AND M_Locator_ID=?"; // 2 + + " AND M_AttributeSetInstance_ID=?"; //3 PreparedStatement pstmt = null; ResultSet rs = null; try @@ -175,8 +171,7 @@ public class CalloutInventory extends CalloutEngine pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, M_Product_ID); pstmt.setInt(2, M_Locator_ID); - if (M_AttributeSetInstance_ID != 0) - pstmt.setInt(3, M_AttributeSetInstance_ID); + pstmt.setInt(3, M_AttributeSetInstance_ID); rs = pstmt.executeQuery(); if (rs.next()) { diff --git a/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java b/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java index ca3014ce41..dac134ad22 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InventoryCountUpdate.java @@ -16,18 +16,12 @@ *****************************************************************************/ package org.compiere.process; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.util.logging.Level; import org.compiere.model.MInventory; -import org.compiere.model.MInventoryLine; import org.compiere.model.MInventoryLineMA; -import org.compiere.model.MStorageOnHand; import org.compiere.util.AdempiereSystemError; import org.compiere.util.DB; -import org.compiere.util.Env; /** * Update existing Inventory Count List with current Book value @@ -92,7 +86,7 @@ public class InventoryCountUpdate extends SvrProcess // ASI sql = new StringBuilder("UPDATE M_InventoryLine l ") .append("SET (QtyBook,QtyCount) = ") - .append("(SELECT QtyOnHand,QtyOnHand FROM M_StorageOnHand s ") + .append("(SELECT SUM(QtyOnHand),SUM(QtyOnHand) FROM M_StorageOnHand s ") .append("WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID") .append(" AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),") .append(" Updated=SysDate,") @@ -105,9 +99,6 @@ public class InventoryCountUpdate extends SvrProcess int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (log.isLoggable(Level.INFO)) log.info("Update with ASI=" + no); - // No ASI - int noMA = updateWithMA(); - // Set Count to Zero if (p_InventoryCountSetZero) { @@ -119,71 +110,11 @@ public class InventoryCountUpdate extends SvrProcess } if (multiple > 0){ - StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append((no + noMA)).append(" --> @InventoryProductMultiple@"); + StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append(no).append(" --> @InventoryProductMultiple@"); return msgreturn.toString(); } StringBuilder msgreturn = new StringBuilder("@M_InventoryLine_ID@ - #").append(no); return msgreturn.toString(); } // doIt - /** - * Update Inventory Lines With Material Allocation - * @return no updated - */ - private int updateWithMA() - { - int no = 0; - // - String sql = "SELECT * FROM M_InventoryLine WHERE M_Inventory_ID=? AND M_AttributeSetInstance_ID=0"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, get_TrxName()); - pstmt.setInt (1, p_M_Inventory_ID); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - MInventoryLine il = new MInventoryLine (getCtx(), rs, get_TrxName()); - BigDecimal onHand = Env.ZERO; - MStorageOnHand[] storages = MStorageOnHand.getAll(getCtx(), il.getM_Product_ID(), il.getM_Locator_ID(), get_TrxName()); - MInventoryLineMA ma = null; - for (int i = 0; i < storages.length; i++) - { - MStorageOnHand storage = storages[i]; - if (storage.getQtyOnHand().signum() == 0) - continue; - onHand = onHand.add(storage.getQtyOnHand()); - // No ASI - if (storage.getM_AttributeSetInstance_ID() == 0 - && storages.length == 1) - continue; - // Save ASI - ma = new MInventoryLineMA (il, - storage.getM_AttributeSetInstance_ID(), storage.getQtyOnHand(),storage.getDateMaterialPolicy(),true); - if (!ma.save()) - ; - } - il.setQtyBook(onHand); - il.setQtyCount(onHand); - if (il.save()) - no++; - } - } - catch (Exception e) - { - log.log (Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - // - if (log.isLoggable(Level.INFO)) log.info("#" + no); - return no; - } // updateWithMA - - } // InventoryCountUpdate From 616a76d4b2a22ab7a7a59e60b8c355ce64272877 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sat, 3 Sep 2016 18:01:51 +0200 Subject: [PATCH 17/21] IDEMPIERE-3177 1005979 Issues with material receipt and lot numbers. --- .../org/compiere/model/MStorageOnHand.java | 101 ++++++++---------- 1 file changed, 44 insertions(+), 57 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java b/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java index ce80f00f7f..bfc4703b74 100644 --- a/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java +++ b/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java @@ -456,7 +456,7 @@ public class MStorageOnHand extends X_M_StorageOnHand * @param ctx context * @param M_Warehouse_ID ignore if M_Locator_ID > 0 * @param M_Product_ID product - * @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance + * @param M_AttributeSetInstance_ID instance id, 0 to retrieve storages that don't have asi, -1 to retrieve all instance * @param minGuaranteeDate optional minimum guarantee date if all attribute instances * @param FiFo first in-first-out * @param M_Locator_ID optional locator id @@ -476,7 +476,7 @@ public class MStorageOnHand extends X_M_StorageOnHand * @param ctx context * @param M_Warehouse_ID ignore if M_Locator_ID > 0 * @param M_Product_ID product - * @param M_AttributeSetInstance_ID instance id, 0 to retrieve all instance + * @param M_AttributeSetInstance_ID instance id, 0 to retrieve storages that don't have asi, -1 to retrieve all instance * @param minGuaranteeDate optional minimum guarantee date if all attribute instances * @param FiFo first in-first-out * @param M_Locator_ID optional locator id @@ -492,79 +492,66 @@ public class MStorageOnHand extends X_M_StorageOnHand if ((M_Warehouse_ID == 0 && M_Locator_ID == 0) || M_Product_ID == 0) return new MStorageOnHand[0]; - boolean allAttributeInstances = false; - if (M_AttributeSetInstance_ID == 0) - allAttributeInstances = true; - ArrayList list = new ArrayList(); - // Specific Attribute Set Instance String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID," + "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy," - + "s.QtyOnHand,s.DateLastInventory,s.DateMaterialPolicy " + + "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy " + "FROM M_StorageOnHand s" - + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) "; + + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID)" + + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) "; if (M_Locator_ID > 0) sql += "WHERE l.M_Locator_ID = ?"; else sql += "WHERE l.M_Warehouse_ID=?"; - sql += " AND s.M_Product_ID=?" - + " AND COALESCE(s.M_AttributeSetInstance_ID,0)=? " + sql += " AND s.M_Product_ID=? " + " AND s.QtyOnHand < 0 "; - sql += "ORDER BY l.PriorityNo DESC, DateMaterialPolicy "; - if (!FiFo) - sql += " DESC"; - // All Attribute Set Instances - if (allAttributeInstances) + + if (minGuaranteeDate != null) { - sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID," - + "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy," - + "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy " - + "FROM M_StorageOnHand s" - + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID)" - + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) "; - if (M_Locator_ID > 0) - sql += "WHERE l.M_Locator_ID = ?"; - else - sql += "WHERE l.M_Warehouse_ID=?"; - sql += " AND s.M_Product_ID=? " - + " AND s.QtyOnHand < 0 "; - - if (minGuaranteeDate != null) - { - sql += "AND (asi.GuaranteeDate IS NULL OR asi.GuaranteeDate>?) "; - } - - MProduct product = MProduct.get(Env.getCtx(), M_Product_ID); - - if(product.isUseGuaranteeDateForMPolicy()){ - sql += "ORDER BY l.PriorityNo DESC, " + - "asi.GuaranteeDate"; - if (!FiFo) - sql += " DESC"; - } - else - { - sql += "ORDER BY l.PriorityNo DESC, l.M_Locator_ID, s.DateMaterialPolicy"; - if (!FiFo) - sql += " DESC"; - } - - sql += ", s.QtyOnHand DESC"; - } + sql += "AND (asi.GuaranteeDate IS NULL OR asi.GuaranteeDate>?) "; + } + + if (M_AttributeSetInstance_ID > 0) + { + sql += "AND s.M_AttributeSetInstance_ID=? "; + } + else if (M_AttributeSetInstance_ID == 0) + { + sql += "AND (s.M_AttributeSetInstance_ID=0 OR s.M_AttributeSetInstance_ID IS NULL) "; + } + + MProduct product = MProduct.get(Env.getCtx(), M_Product_ID); + + if(product.isUseGuaranteeDateForMPolicy()){ + sql += "ORDER BY l.PriorityNo DESC, " + + "asi.GuaranteeDate"; + if (!FiFo) + sql += " DESC"; + } + else + { + sql += "ORDER BY l.PriorityNo DESC, l.M_Locator_ID, s.DateMaterialPolicy"; + if (!FiFo) + sql += " DESC"; + } + + sql += ", s.QtyOnHand DESC"; + PreparedStatement pstmt = null; ResultSet rs = null; try { + int index = 0; pstmt = DB.prepareStatement(sql, trxName); - pstmt.setInt(1, M_Locator_ID > 0 ? M_Locator_ID : M_Warehouse_ID); - pstmt.setInt(2, M_Product_ID); - if (!allAttributeInstances) + pstmt.setInt(++index, M_Locator_ID > 0 ? M_Locator_ID : M_Warehouse_ID); + pstmt.setInt(++index, M_Product_ID); + if (minGuaranteeDate != null) { - pstmt.setInt(3, M_AttributeSetInstance_ID); + pstmt.setTimestamp(++index, minGuaranteeDate); } - else if (minGuaranteeDate != null) + if (M_AttributeSetInstance_ID > 0) { - pstmt.setTimestamp(3, minGuaranteeDate); + pstmt.setInt(++index, M_AttributeSetInstance_ID); } rs = pstmt.executeQuery(); while (rs.next()) From 46b7bc39a725726c2ebccc34bc751b66b68082bd Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Mon, 6 Jun 2016 11:40:23 +0800 Subject: [PATCH 18/21] IDEMPIERE-2668 Exclude Locators for Demand Operations --- migration/i3.1/oracle/201606061100_IDEMPIERE-2668.sql | 10 ++++++++++ .../i3.1/postgresql/201606061100_IDEMPIERE-2668.sql | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 migration/i3.1/oracle/201606061100_IDEMPIERE-2668.sql create mode 100644 migration/i3.1/postgresql/201606061100_IDEMPIERE-2668.sql diff --git a/migration/i3.1/oracle/201606061100_IDEMPIERE-2668.sql b/migration/i3.1/oracle/201606061100_IDEMPIERE-2668.sql new file mode 100644 index 0000000000..51a08f856c --- /dev/null +++ b/migration/i3.1/oracle/201606061100_IDEMPIERE-2668.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jun 6, 2016 10:53:34 AM SGT +-- IDEMPIERE-2668 Exclude Locators for Demand Operations +UPDATE AD_Field SET IsMandatory='Y',Updated=TO_DATE('2016-06-06 10:53:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200649 +; + +SELECT register_migration_script('201606061100_IDEMPIERE-2668.sql') FROM dual +; diff --git a/migration/i3.1/postgresql/201606061100_IDEMPIERE-2668.sql b/migration/i3.1/postgresql/201606061100_IDEMPIERE-2668.sql new file mode 100644 index 0000000000..125f517be2 --- /dev/null +++ b/migration/i3.1/postgresql/201606061100_IDEMPIERE-2668.sql @@ -0,0 +1,7 @@ +-- Jun 6, 2016 10:53:34 AM SGT +-- IDEMPIERE-2668 Exclude Locators for Demand Operations +UPDATE AD_Field SET IsMandatory='Y',Updated=TO_TIMESTAMP('2016-06-06 10:53:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200649 +; + +SELECT register_migration_script('201606061100_IDEMPIERE-2668.sql') FROM dual +; From 916341f634eac0cb014e8580b86426f1f0aab7fd Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 3 Sep 2016 18:26:55 +0200 Subject: [PATCH 19/21] IDEMPIERE-2470 IDEMPIERE-369 IDEMPIERE-520 make uniform ZK_PAGING_SIZE per client --- .../WEB-INF/src/org/adempiere/webui/adwindow/GridView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java index 8723226617..f9e35aca28 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java @@ -163,7 +163,7 @@ public class GridView extends Vbox implements EventListener, IdSpace, IFi } else { - pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, DEFAULT_PAGE_SIZE); + pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, DEFAULT_PAGE_SIZE, Env.getAD_Client_ID(Env.getCtx())); String limit = Library.getProperty(CustomGridDataLoader.GRID_DATA_LOADER_LIMIT); if (limit == null || !(limit.equals(Integer.toString(pageSize)))) { Library.setProperty(CustomGridDataLoader.GRID_DATA_LOADER_LIMIT, Integer.toString(pageSize)); @@ -196,7 +196,7 @@ public class GridView extends Vbox implements EventListener, IdSpace, IFi public void setDetailPaneMode(boolean detailPaneMode) { if (this.detailPaneMode != detailPaneMode) { this.detailPaneMode = detailPaneMode; - pageSize = detailPaneMode ? DEFAULT_DETAIL_PAGE_SIZE : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20); + pageSize = detailPaneMode ? DEFAULT_DETAIL_PAGE_SIZE : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20, Env.getAD_Client_ID(Env.getCtx())); updatePaging(); } } From 779aace1ccc48e47f718a8c2da15431e497e855e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 3 Sep 2016 18:29:39 +0200 Subject: [PATCH 20/21] Security issue - passwords must not be written in logs --- org.adempiere.base/src/org/compiere/model/MUser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MUser.java b/org.adempiere.base/src/org/compiere/model/MUser.java index 99e5541b32..130d03e931 100644 --- a/org.adempiere.base/src/org/compiere/model/MUser.java +++ b/org.adempiere.base/src/org/compiere/model/MUser.java @@ -173,7 +173,7 @@ public class MUser extends X_AD_User { if (name == null || name.length() == 0 || password == null || password.length() == 0) { - s_log.warning ("Invalid Name/Password = " + name + "/" + password); + s_log.warning ("Invalid Name/Password = " + name); return null; } boolean hash_password = MSysConfig.getBooleanValue(MSysConfig.USER_PASSWORD_HASH, false); From 60cc3c8364513fee2e5daac1435e38a98d703874 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 3 Sep 2016 18:40:20 +0200 Subject: [PATCH 21/21] IDEMPIERE-3178 Can't login to iDempiere monitor if same user/pass exist in a tenant --- org.adempiere.base/src/org/compiere/model/MUser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MUser.java b/org.adempiere.base/src/org/compiere/model/MUser.java index 130d03e931..fa6a3b5f47 100644 --- a/org.adempiere.base/src/org/compiere/model/MUser.java +++ b/org.adempiere.base/src/org/compiere/model/MUser.java @@ -198,7 +198,7 @@ public class MUser extends X_AD_User List users = new Query(ctx, MUser.Table_Name, where.toString(), null) .setParameters(name) - .setOrderBy(MUser.COLUMNNAME_AD_User_ID) + .setOrderBy("AD_Client_ID, AD_User_ID") // prefer first user on System .list(); if (users.size() == 0) { @@ -223,6 +223,7 @@ public class MUser extends X_AD_User if (valid){ retValue=user; + break; } }