IDEMPIERE-1026 Button on table to create automatically the window (#565)

Solve issue with SeqNo=0
This commit is contained in:
Carlos Ruiz 2021-02-02 12:26:15 +01:00 committed by GitHub
parent 0f263f1c79
commit e099498a69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 10 deletions

View File

@ -119,6 +119,7 @@ public class CreateWindowFromTable extends SvrProcess
throw new AdempiereException(Msg.getMsg(getCtx(), "NewWindowNoValid")); throw new AdempiereException(Msg.getMsg(getCtx(), "NewWindowNoValid"));
MWindow window; MWindow window;
int tabSeqNo = 0;
if (p_isNewWindow) { if (p_isNewWindow) {
if (MWindow.WINDOWTYPE_Transaction.equals(p_WindowType) && if (MWindow.WINDOWTYPE_Transaction.equals(p_WindowType) &&
table.getColumnIndex("Processed") <= 0) table.getColumnIndex("Processed") <= 0)
@ -137,6 +138,8 @@ public class CreateWindowFromTable extends SvrProcess
window.saveEx(); window.saveEx();
addLog(window.getAD_Window_ID(), null, null, "@AD_Window_ID@: " + window.getName(), addLog(window.getAD_Window_ID(), null, null, "@AD_Window_ID@: " + window.getName(),
window.get_Table_ID(), window.getAD_Window_ID()); window.get_Table_ID(), window.getAD_Window_ID());
p_TabLevel = 0;
tabSeqNo = 10;
} else { } else {
//If no new window but a detail tab //If no new window but a detail tab
if (p_TabLevel > 0) { if (p_TabLevel > 0) {
@ -152,21 +155,27 @@ public class CreateWindowFromTable extends SvrProcess
throw new AdempiereException(Msg.getMsg(getCtx(), "NoParentLink")); throw new AdempiereException(Msg.getMsg(getCtx(), "NoParentLink"));
} }
window = new MWindow(getCtx(), p_AD_Window_ID, get_TrxName()); window = new MWindow(getCtx(), p_AD_Window_ID, get_TrxName());
if (p_TabLevel > 1) { int maxTabLevel = -1;
int maxTabLevel = 0; int maxTabSeqNo = 0;
for (MTab tab : window.getTabs(false, get_TrxName())) { for (MTab tab : window.getTabs(true, get_TrxName())) {
if (tab.getTabLevel() > maxTabLevel) { if (tab.getTabLevel() > maxTabLevel) {
maxTabLevel = tab.getTabLevel(); maxTabLevel = tab.getTabLevel();
} }
if (tab.getSeqNo() > maxTabSeqNo) {
maxTabSeqNo = tab.getSeqNo();
} }
if (maxTabLevel+1 < p_TabLevel)
throw new AdempiereException(Msg.getMsg(getCtx(), "MaxTabLevel", new Object[] {maxTabLevel+1}));
} }
tabSeqNo = maxTabSeqNo + 10;
if ( (maxTabLevel == 0 && p_TabLevel == 0)
|| p_TabLevel > maxTabLevel+1)
throw new AdempiereException(Msg.getMsg(getCtx(), "MaxTabLevel", new Object[] {maxTabLevel+1}));
} }
MTab tab = new MTab(window); MTab tab = new MTab(window);
tab.setSeqNo(tabSeqNo);
tab.setName(table.getName()); tab.setName(table.getName());
tab.setAD_Table_ID(p_AD_Table_ID); tab.setAD_Table_ID(p_AD_Table_ID);
tab.setTabLevel(p_TabLevel); tab.setTabLevel(p_TabLevel);