Fix bug when checking if the process is already configured
Reported by AFalcone and suggested fix here -> http://red1.org/adempiere/viewtopic.php?f=34&t=1193 Also refactored the generation of the process to make it smart in case a new tab is added to a window and it requires to configure new processes
This commit is contained in:
parent
7cb32f8039
commit
cf96e249c8
|
@ -178,38 +178,43 @@ public class ASPGenerateLevel extends SvrProcess
|
||||||
}
|
}
|
||||||
// tabs
|
// tabs
|
||||||
for (MTab tab : window.getTabs(true, get_TrxName())) {
|
for (MTab tab : window.getTabs(true, get_TrxName())) {
|
||||||
if (DB.getSQLValueEx(
|
int asp_tab_id = DB.getSQLValueEx(get_TrxName(),
|
||||||
get_TrxName(),
|
"SELECT ASP_Tab_ID FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?",
|
||||||
"SELECT COUNT(*) FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?",
|
asp_window_id, tab.getAD_Tab_ID());
|
||||||
asp_window_id, tab.getAD_Tab_ID()) < 1) {
|
X_ASP_Tab aspTab = null;
|
||||||
X_ASP_Tab aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName());
|
if (asp_tab_id < 1) {
|
||||||
|
aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName());
|
||||||
aspTab.setASP_Window_ID(asp_window_id);
|
aspTab.setASP_Window_ID(asp_window_id);
|
||||||
aspTab.setAD_Tab_ID(tab.getAD_Tab_ID());
|
aspTab.setAD_Tab_ID(tab.getAD_Tab_ID());
|
||||||
aspTab.setASP_Status(p_ASP_Status);
|
aspTab.setASP_Status(p_ASP_Status);
|
||||||
aspTab.setAllFields(! p_IsGenerateFields);
|
aspTab.setAllFields(! p_IsGenerateFields);
|
||||||
if (aspTab.save())
|
if (aspTab.save()) {
|
||||||
noTabs++;
|
noTabs++;
|
||||||
// fields
|
asp_tab_id = aspTab.getASP_Tab_ID();
|
||||||
for (MField field : tab.getFields(true, get_TrxName())) {
|
}
|
||||||
if (p_IsGenerateFields) {
|
} else {
|
||||||
if (DB.getSQLValueEx(
|
aspTab = new X_ASP_Tab(getCtx(), asp_tab_id, get_TrxName());
|
||||||
get_TrxName(),
|
}
|
||||||
"SELECT COUNT(*) FROM ASP_Field WHERE ASP_Tab_ID = ? AND AD_Field_ID = ?",
|
// fields
|
||||||
aspTab.getASP_Tab_ID(), field.getAD_Field_ID()) < 1) {
|
for (MField field : tab.getFields(true, get_TrxName())) {
|
||||||
X_ASP_Field aspField = new X_ASP_Field(getCtx(), 0, get_TrxName());
|
if (p_IsGenerateFields) {
|
||||||
aspField.setASP_Tab_ID(aspTab.getASP_Tab_ID());
|
if (DB.getSQLValueEx(
|
||||||
aspField.setAD_Field_ID(field.getAD_Field_ID());
|
get_TrxName(),
|
||||||
aspField.setASP_Status(p_ASP_Status);
|
"SELECT COUNT(*) FROM ASP_Field WHERE ASP_Tab_ID = ? AND AD_Field_ID = ?",
|
||||||
if (aspField.save())
|
aspTab.getASP_Tab_ID(), field.getAD_Field_ID()) < 1) {
|
||||||
noFields++;
|
X_ASP_Field aspField = new X_ASP_Field(getCtx(), 0, get_TrxName());
|
||||||
}
|
aspField.setASP_Tab_ID(aspTab.getASP_Tab_ID());
|
||||||
|
aspField.setAD_Field_ID(field.getAD_Field_ID());
|
||||||
|
aspField.setASP_Status(p_ASP_Status);
|
||||||
|
if (aspField.save())
|
||||||
|
noFields++;
|
||||||
}
|
}
|
||||||
// verify if a field is a button and assign permission to the corresponding process
|
}
|
||||||
MColumn column = MColumn.get(getCtx(), field.getAD_Column_ID());
|
// verify if a field is a button and assign permission to the corresponding process
|
||||||
if (column.getAD_Reference_ID() == DisplayType.Button) {
|
MColumn column = MColumn.get(getCtx(), field.getAD_Column_ID());
|
||||||
if (column.getAD_Process_ID() > 0) {
|
if (column.getAD_Reference_ID() == DisplayType.Button) {
|
||||||
generateProcess(column.getAD_Process_ID());
|
if (column.getAD_Process_ID() > 0) {
|
||||||
}
|
generateProcess(column.getAD_Process_ID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +259,7 @@ public class ASPGenerateLevel extends SvrProcess
|
||||||
// Add Process and Parameters
|
// Add Process and Parameters
|
||||||
MProcess process = new MProcess(getCtx(), p_AD_Process_ID, get_TrxName());
|
MProcess process = new MProcess(getCtx(), p_AD_Process_ID, get_TrxName());
|
||||||
int asp_process_id = DB.getSQLValueEx(get_TrxName(),
|
int asp_process_id = DB.getSQLValueEx(get_TrxName(),
|
||||||
"SELECT COUNT(*) FROM ASP_Process WHERE ASP_Level_ID = ? AND AD_Process_ID = ?",
|
"SELECT ASP_Process_ID FROM ASP_Process WHERE ASP_Level_ID = ? AND AD_Process_ID = ?",
|
||||||
p_ASP_Level_ID, process.getAD_Process_ID());
|
p_ASP_Level_ID, process.getAD_Process_ID());
|
||||||
X_ASP_Process aspProcess = null;
|
X_ASP_Process aspProcess = null;
|
||||||
if (asp_process_id < 1) {
|
if (asp_process_id < 1) {
|
||||||
|
|
Loading…
Reference in New Issue