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..d6f1bdea41 --- /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='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 new file mode 100644 index 0000000000..355ae58887 --- /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='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 +; 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()); diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index 9570589e16..079be7b0b0 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, ""); @@ -3847,4 +3867,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.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 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 d32c43efda..7e9821408f 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 @@ -108,6 +108,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.Menuitem; import org.zkoss.zul.Menupopup; import org.zkoss.zul.Window.Mode; @@ -1668,9 +1669,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() */ 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++) {