IDEMPIERE-2679 Account panel : propose confirmation before closing

This commit is contained in:
Nicolas Micoud 2015-07-08 08:56:52 -05:00
parent fdabb11e56
commit 279fc48ee1
3 changed files with 107 additions and 9 deletions

View File

@ -0,0 +1,14 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-2679 Account panel : propose confirmation before closing
-- Jul 3, 2015 9:48:50 PM 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','Do you want to create a new account combination ?',0,0,'Y',TO_DATE('2015-07-03 21:48:49','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2015-07-03 21:48:49','YYYY-MM-DD HH24:MI:SS'),100,200354,'CreateNewAccountCombination','D','e66e11ee-9f0c-4fac-a057-14a6cf820e43')
;
-- Jul 3, 2015 9:49:14 PM CEST
UPDATE AD_Message SET Value='CreateNewAccountCombination?',Updated=TO_DATE('2015-07-03 21:49:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200354
;
SELECT register_migration_script('201507032149_IDEMPIERE-2679.sql') FROM dual
;

View File

@ -0,0 +1,11 @@
-- IDEMPIERE-2679 Account panel : propose confirmation before closing
-- Jul 3, 2015 9:48:50 PM 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','Do you want to create a new account combination ?',0,0,'Y',TO_TIMESTAMP('2015-07-03 21:48:49','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2015-07-03 21:48:49','YYYY-MM-DD HH24:MI:SS'),100,200354,'CreateNewAccountCombination','D','e66e11ee-9f0c-4fac-a057-14a6cf820e43')
;
-- Jul 3, 2015 9:49:14 PM CEST
UPDATE AD_Message SET Value='CreateNewAccountCombination?',Updated=TO_TIMESTAMP('2015-07-03 21:49:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200354
;
SELECT register_migration_script('201507032149_IDEMPIERE-2679.sql') FROM dual
;

View File

@ -16,6 +16,8 @@
*****************************************************************************/
package org.adempiere.webui.window;
import static org.compiere.model.SystemIDs.WINDOW_ACCOUNTCOMBINATION;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -50,7 +52,6 @@ import org.compiere.model.MAccountLookup;
import org.compiere.model.MAcctSchema;
import org.compiere.model.MAcctSchemaElement;
import org.compiere.model.MQuery;
import static org.compiere.model.SystemIDs.*;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
@ -61,14 +62,14 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Cell;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Div;
import org.zkoss.zul.Groupbox;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Vbox;
/**
@ -79,8 +80,7 @@ import org.zkoss.zul.Vbox;
public final class WAccountDialog extends Window
implements EventListener<Event>, DataStatusListener, ValueChangeListener
{
private static final long serialVersionUID = 7999516267209766287L;
private static final long serialVersionUID = -1684167361808052482L;
private Callback<Integer> m_callback;
/**
@ -143,6 +143,8 @@ public final class WAccountDialog extends Window
private int m_AD_Client_ID;
/** Where clause for combination search */
private MQuery m_query;
/** Current combination */
private int IDvalue = 0;
/** Logger */
private static CLogger log = CLogger.getCLogger(WAccountDialog.class);
@ -172,6 +174,8 @@ public final class WAccountDialog extends Window
private Row m_row;
private Rows m_rows;
/**
* Static component init.
* <pre>
@ -629,8 +633,53 @@ public final class WAccountDialog extends Window
public void onEvent(Event event) throws Exception {
if (event.getTarget().getId().equals("Ok"))
{
m_changed = true;
dispose();
// Compare all data to propose creation/update of combination
MAccount combiOrg = new MAccount(Env.getCtx(), IDvalue > 0 ? IDvalue : m_mAccount.C_ValidCombination_ID, null);
boolean needconfirm = false;
if (needConfirm(f_AD_Org_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_Account_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_SubAcct_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_C_BPartner_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_M_Product_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_C_Activity_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_C_LocFrom_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_C_LocTo_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_C_Campaign_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_AD_OrgTrx_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_C_Project_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_C_SalesRegion_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_User1_ID, combiOrg))
needconfirm = true;
else if (needConfirm(f_User2_ID, combiOrg))
needconfirm = true;
if (needconfirm) {
FDialog.ask(m_WindowNo, this, "CreateNewAccountCombination?", new Callback<Boolean>() {
public void onCallback(Boolean result) {
if (result) {
action_Save();
m_changed = true;
dispose();
}
}
});
} else {
m_changed = true;
dispose();
}
}
else if (event.getTarget().getId().equals("Cancel"))
{
@ -647,6 +696,31 @@ public final class WAccountDialog extends Window
action_Find (true);
}
boolean needConfirm(WEditor editor, MAccount combiOrg)
{
if (editor != null ) {
String columnName = editor.getColumnName();
if (log.isLoggable(Level.FINE)) log.fine("columnName : " + columnName + " : " + combiOrg.get_Value(columnName) + " - " + editor.getValue());
if (columnName.equals("AD_Org_ID") || columnName.equals("AD_OrgTrx_ID")) { // 0 can be a correct value for orgs
if((combiOrg.get_Value(columnName) == null && editor.getValue() != null && !"".equals(String.valueOf(editor.getValue())))
|| (combiOrg.get_Value(columnName) != null && combiOrg.get_ValueAsInt(columnName) >= 0 && editor.getValue() == null)
|| (editor.getValue() != null && !"".equals(String.valueOf(editor.getValue())) && combiOrg.get_ValueAsInt(columnName) != (Integer) editor.getValue())) {
return true;
}
} else {
if((combiOrg.get_ValueAsInt(columnName) == 0 && editor.getValue() != null && !"".equals(String.valueOf(editor.getValue())))
|| combiOrg.get_ValueAsInt(columnName) > 0 && editor.getValue() == null
|| (editor.getValue() != null && !"".equals(String.valueOf(editor.getValue())) && combiOrg.get_ValueAsInt(columnName) != (Integer) editor.getValue())) {
return true;
}
}
}
return false;
}
/**
* Status Change Listener
* @param e event
@ -919,7 +993,6 @@ public final class WAccountDialog extends Window
*/
sql.append("AD_Client_ID=? AND C_AcctSchema_ID=?");
if (log.isLoggable(Level.FINE)) log.fine("Check = " + sql.toString());
int IDvalue = 0;
String Alias = null;
PreparedStatement pstmt = null;
ResultSet rs = null;