From b9ea0e6c85d078d94c2113eff9e6dfda5caac690 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 16 Dec 2013 14:43:55 +0800 Subject: [PATCH 1/6] 1003579 Improve check for BOM child records with zero quantity. --- migration/i2.0/oracle/201312131400_Ticket_1003579.sql | 8 ++++++++ migration/i2.0/postgresql/201312131400_Ticket_1003579.sql | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 migration/i2.0/oracle/201312131400_Ticket_1003579.sql create mode 100644 migration/i2.0/postgresql/201312131400_Ticket_1003579.sql diff --git a/migration/i2.0/oracle/201312131400_Ticket_1003579.sql b/migration/i2.0/oracle/201312131400_Ticket_1003579.sql new file mode 100644 index 0000000000..788ec2737c --- /dev/null +++ b/migration/i2.0/oracle/201312131400_Ticket_1003579.sql @@ -0,0 +1,8 @@ +-- Dec 13, 2013 1:43:47 PM COT +-- Ticket: 1003579 - Improve check for BOM child records with zero quantity +UPDATE AD_Column SET ValueMin='1',Updated=TO_DATE('2013-12-13 13:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4723 +; + +SELECT register_migration_script('201312131400_Ticket_1003579.sql') FROM dual +; + diff --git a/migration/i2.0/postgresql/201312131400_Ticket_1003579.sql b/migration/i2.0/postgresql/201312131400_Ticket_1003579.sql new file mode 100644 index 0000000000..6f2dbca319 --- /dev/null +++ b/migration/i2.0/postgresql/201312131400_Ticket_1003579.sql @@ -0,0 +1,7 @@ +-- Dec 13, 2013 1:43:47 PM COT +-- Ticket: 1003579 - Improve check for BOM child records with zero quantity +UPDATE AD_Column SET ValueMin='1',Updated=TO_TIMESTAMP('2013-12-13 13:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4723 +; + +SELECT register_migration_script('201312131400_Ticket_1003579.sql') FROM dual +; \ No newline at end of file From c7e8bd965d5b9b57efd51118ec80b79b7b54d898 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 16 Dec 2013 15:45:07 -0500 Subject: [PATCH 2/6] 1003579 Improve check for BOM child records with zero quantity. / peer review --- migration/i2.0/oracle/201312131400_Ticket_1003579.sql | 2 +- migration/i2.0/postgresql/201312131400_Ticket_1003579.sql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/i2.0/oracle/201312131400_Ticket_1003579.sql b/migration/i2.0/oracle/201312131400_Ticket_1003579.sql index 788ec2737c..d6f1bdea41 100644 --- a/migration/i2.0/oracle/201312131400_Ticket_1003579.sql +++ b/migration/i2.0/oracle/201312131400_Ticket_1003579.sql @@ -1,6 +1,6 @@ -- Dec 13, 2013 1:43:47 PM COT -- Ticket: 1003579 - Improve check for BOM child records with zero quantity -UPDATE AD_Column SET ValueMin='1',Updated=TO_DATE('2013-12-13 13:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4723 +UPDATE AD_Column SET ValueMin='0.0000000001',Updated=TO_DATE('2013-12-13 13:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4723 ; SELECT register_migration_script('201312131400_Ticket_1003579.sql') FROM dual diff --git a/migration/i2.0/postgresql/201312131400_Ticket_1003579.sql b/migration/i2.0/postgresql/201312131400_Ticket_1003579.sql index 6f2dbca319..355ae58887 100644 --- a/migration/i2.0/postgresql/201312131400_Ticket_1003579.sql +++ b/migration/i2.0/postgresql/201312131400_Ticket_1003579.sql @@ -1,7 +1,7 @@ -- Dec 13, 2013 1:43:47 PM COT -- Ticket: 1003579 - Improve check for BOM child records with zero quantity -UPDATE AD_Column SET ValueMin='1',Updated=TO_TIMESTAMP('2013-12-13 13:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4723 +UPDATE AD_Column SET ValueMin='0.0000000001',Updated=TO_TIMESTAMP('2013-12-13 13:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4723 ; SELECT register_migration_script('201312131400_Ticket_1003579.sql') FROM dual -; \ No newline at end of file +; From b58546521f85a2adb5be029eb27d7318bff2eeeb Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 17 Dec 2013 10:44:06 +0800 Subject: [PATCH 3/6] 1003572 Problem with Locator field on "Import Inventory" process. Fixed wrong checking for "first locator element is empty". --- .../org/adempiere/webui/window/WLocatorDialog.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java index b7db1d0f50..e2a5ea540f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java @@ -304,8 +304,18 @@ public class WLocatorDialog extends Window implements EventListener if (log.isLoggable(Level.FINE)) log.fine(m_mLocator.toString()); - if (m_mLocator.getSize()==0 || (m_mLocator.getSize()==1 && m_mLocator.get(m_mLocator.getElementAt(0))==null)) - throw new AdempiereUserError(Msg.getMsg(Env.getCtx(), "DRP-001", false)); + if (m_mLocator.getSize()==0) + { + throw new AdempiereUserError(Msg.getMsg(Env.getCtx(), "DRP-001", false)); + } + else if (m_mLocator.getSize()==1) + { + MLocator locator = (MLocator) m_mLocator.getElementAt(0); + if (locator == null || locator.getM_Locator_ID() <= 0) + { + throw new AdempiereUserError(Msg.getMsg(Env.getCtx(), "DRP-001", false)); + } + } for (int i = 0; i < m_mLocator.getSize(); i++) { From 0e6d317e2b847c29fb6439c76e1246ee62d2f047 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 17 Dec 2013 18:04:50 +0800 Subject: [PATCH 4/6] 1003581 IDEMPIERE-1584 -- Custom sort order is lost when updating a record. --- .../src/org/compiere/model/GridTable.java | 38 ++++++++++++++++--- .../adwindow/AbstractADWindowContent.java | 32 ++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index bec1206e6f..2cbe2efa1b 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -101,7 +101,7 @@ public class GridTable extends AbstractTableModel /** * */ - private static final long serialVersionUID = -2181155164268688340L; + private static final long serialVersionUID = 4223765688790104180L; public static final String DATA_REFRESH_MESSAGE = "Refreshed"; @@ -232,6 +232,10 @@ public class GridTable extends AbstractTableModel private final static Integer NEW_ROW_ID = Integer.valueOf(-1); private static final int DEFAULT_FETCH_SIZE = 200; + /** Keep track of last sorted column index and sort direction */ + private int m_lastSortColumnIndex = -1; + private boolean m_lastSortedAscending = true; + /** * Set Table Name * @param newTableName table name @@ -890,6 +894,13 @@ public class GridTable extends AbstractTableModel } if (getRowCount() == 0) return; + + boolean isSameSortEntries = (col == m_lastSortColumnIndex && ascending == m_lastSortedAscending); + if (!isSameSortEntries) + { + m_lastSortColumnIndex = col; + m_lastSortedAscending = ascending; + } //cache changed row Object[] changedRow = m_rowChanged >= 0 ? getDataAtRow(m_rowChanged) : null; @@ -948,10 +959,14 @@ public class GridTable extends AbstractTableModel m_sort.get(i).data = null; } } - // update UI - fireTableDataChanged(); - // Info detected by MTab.dataStatusChanged and current row set to 0 - fireDataStatusIEvent("Sorted", "#" + m_sort.size()); + + if (!isSameSortEntries) + { + // update UI + fireTableDataChanged(); + // Info detected by MTab.dataStatusChanged and current row set to 0 + fireDataStatusIEvent("Sorted", "#" + m_sort.size()); + } } // sort /** @@ -2919,6 +2934,11 @@ public class GridTable extends AbstractTableModel m_changed = false; m_rowChanged = -1; m_inserting = false; + if (m_lastSortColumnIndex >= 0) + { + loadComplete(); + sort(m_lastSortColumnIndex, m_lastSortedAscending); + } fireTableDataChanged(); if (fireStatusEvent) fireDataStatusIEvent(DATA_REFRESH_MESSAGE, ""); @@ -3842,4 +3862,12 @@ public class GridTable extends AbstractTableModel public String get_TrxName() { return m_trxName; } + + /** + * reset the cache sort state ( sort column and sort ascending ) + */ + public void resetCacheSortState() { + m_lastSortColumnIndex = -1; + m_lastSortedAscending = true; + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index e95ed650cb..60c8b05694 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -115,6 +115,7 @@ import org.zkoss.zk.ui.util.Clients; import org.zkoss.zul.Column; import org.zkoss.zul.Columns; import org.zkoss.zul.Div; +import org.zkoss.zul.Grid; import org.zkoss.zul.Hbox; import org.zkoss.zul.Listitem; import org.zkoss.zul.Menuitem; @@ -1656,9 +1657,40 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements */ public void onRefresh() { + GridTab gridTab = adTabbox.getSelectedGridTab(); + if (gridTab != null && gridTab.getTableModel() != null) + { + gridTab.getTableModel().resetCacheSortState(); + } + Column sortColumn = findCurrentSortColumn(); onRefresh(true, false); + if (sortColumn != null) + { + sortColumn.setSortDirection("natural"); + } } + private Column findCurrentSortColumn() { + IADTabpanel iadtabpanel = getADTab().getSelectedTabpanel(); + if (iadtabpanel instanceof ADTabpanel) { + ADTabpanel adtabpanel = (ADTabpanel) iadtabpanel; + Grid grid = adtabpanel.getGridView().getListbox(); + Columns columns = grid.getColumns(); + List list = columns.getChildren(); + for(int i = 0; i < list.size(); i++) + { + Component c = (Component) list.get(i); + if (c instanceof Column) { + Column column = (Column) c; + if (!"natural".equals(column.getSortDirection())) { + return column; + } + } + } + } + return null; + } + /** * @see ToolbarListener#onHelp() */ From 9c9a42c4c6b4e1b6be8cfbce88bb225d9532b1ba Mon Sep 17 00:00:00 2001 From: Thomas Bayen Date: Tue, 17 Dec 2013 10:48:52 -0500 Subject: [PATCH 5/6] IDEMPIERE-1636 ImportBankStatement process uses wrong order in sql --- .../src/org/compiere/process/ImportBankStatement.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java b/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java index a160cd5488..64c0aa482d 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportBankStatement.java @@ -364,7 +364,7 @@ public class ImportBankStatement extends SvrProcess //Import Bank Statement sql = new StringBuilder("SELECT * FROM I_BankStatement") .append(" WHERE I_IsImported='N'") - .append(" ORDER BY C_BankAccount_ID, Name, EftStatementDate, EftStatementReference"); + .append(" ORDER BY C_BankAccount_ID, Name, StatementDate, ReferenceNo"); MBankStatement statement = null; MBankAccount account = null; @@ -448,7 +448,7 @@ public class ImportBankStatement extends SvrProcess statement.setDescription(imp.getDescription()); statement.setEftStatementReference(imp.getEftStatementReference()); statement.setEftStatementDate(imp.getEftStatementDate()); - if (statement.save()) + if (statement.save(get_TrxName())) { noInsert++; } @@ -496,7 +496,7 @@ public class ImportBankStatement extends SvrProcess line.setEftAmt(imp.getEftAmt()); // Save statement line - if (line.save()) + if (line.save(get_TrxName())) { imp.setC_BankStatement_ID(statement.getC_BankStatement_ID()); imp.setC_BankStatementLine_ID(line.getC_BankStatementLine_ID()); From 6ed966a30774e08c5fc7b9e8cac9a224e1431643 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 17 Dec 2013 11:47:12 -0500 Subject: [PATCH 6/6] IDEMPIERE-1532 Reversed Allocation document has wrong TrxDate / based on patch from Thomas Bayen (tbayen) --- org.adempiere.base/src/org/compiere/model/MPayment.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 9ddbe060b3..96447ccfb5 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -2200,6 +2200,7 @@ public final class MPayment extends X_C_Payment Msg.translate(getCtx(), "C_Payment_ID") + ": " + getDocumentNo(), get_TrxName()); alloc.setAD_Org_ID(getAD_Org_ID()); + alloc.setDateAcct(getDateAcct()); // in case date acct is different from datetrx in payment; IDEMPIERE-1532 tbayen if (!alloc.save()) { log.severe("P.Allocations not created"); @@ -2628,10 +2629,11 @@ public final class MPayment extends X_C_Payment // Create automatic Allocation MAllocationHdr alloc = new MAllocationHdr (getCtx(), false, - ( accrual ? dateAcct : getDateTrx() ), + getDateTrx(), getC_Currency_ID(), Msg.translate(getCtx(), "C_Payment_ID") + ": " + reversal.getDocumentNo(), get_TrxName()); alloc.setAD_Org_ID(getAD_Org_ID()); + alloc.setDateAcct(dateAcct); // dateAcct variable already take into account the accrual parameter alloc.saveEx(get_TrxName()); // Original Allocation