hg merge release-2.1 (merge release2.1 into development)

This commit is contained in:
Carlos Ruiz 2014-12-28 12:51:27 -05:00
commit 1267117906
26 changed files with 400 additions and 325 deletions

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Dec 23, 2014 11:08:01 PM COT
-- IDEMPIERE-2370 SaaS Generate on menu option
UPDATE AD_Process_Para SET AD_Reference_Value_ID=NULL,Updated=TO_DATE('2014-12-23 23:08:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53128
;
-- Dec 23, 2014 11:24:40 PM COT
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_DATE('2014-12-23 23:24:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53128
;
SELECT register_migration_script('201412232308_SaaSMenu.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- Dec 23, 2014 11:08:01 PM COT
-- IDEMPIERE-2370 SaaS Generate on menu option
UPDATE AD_Process_Para SET AD_Reference_Value_ID=NULL,Updated=TO_TIMESTAMP('2014-12-23 23:08:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53128
;
-- Dec 23, 2014 11:24:40 PM COT
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_TIMESTAMP('2014-12-23 23:24:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=53128
;
SELECT register_migration_script('201412232308_SaaSMenu.sql') FROM dual
;

View File

@ -41,6 +41,7 @@ import org.compiere.model.MProcess;
import org.compiere.model.MProcessPara;
import org.compiere.model.MTab;
import org.compiere.model.MTask;
import org.compiere.model.MToolBarButton;
import org.compiere.model.MTree;
import org.compiere.model.MTreeNode;
import org.compiere.model.MWindow;
@ -56,6 +57,7 @@ import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.wf.MWFNode;
import org.compiere.wf.MWorkflow;
/**
@ -122,7 +124,7 @@ public class ASPGenerateLevel extends SvrProcess
node = thisTree.getRoot();
// Navigate the menu and add every non-summary node
if (node != null && node.isSummary())
if (node != null)
{
Enumeration<?> en = node.preorderEnumeration();
while (en.hasMoreElements())
@ -158,98 +160,13 @@ public class ASPGenerateLevel extends SvrProcess
MMenu menu = new MMenu(getCtx(), nn.getNode_ID(), get_TrxName());
if (menu.getAction().equals(MMenu.ACTION_Window)) {
MWindow window = new MWindow(getCtx(), menu.getAD_Window_ID(), get_TrxName());
int asp_window_id = DB.getSQLValueEx(get_TrxName(),
"SELECT ASP_Window_ID FROM ASP_Window WHERE ASP_Level_ID = ? AND AD_Window_ID = ?",
p_ASP_Level_ID, window.getAD_Window_ID());
X_ASP_Window aspWindow = null;
if (asp_window_id < 1) {
// Add Window, Tabs and Fields (if IsGenerateFields)
aspWindow = new X_ASP_Window(getCtx(), 0, get_TrxName());
aspWindow.setASP_Level_ID(p_ASP_Level_ID);
aspWindow.setAD_Window_ID(window.getAD_Window_ID());
aspWindow.setASP_Status(p_ASP_Status);
if (aspWindow.save()) {
noWindows++;
asp_window_id = aspWindow.getASP_Window_ID();
}
} else {
aspWindow = new X_ASP_Window(getCtx(), asp_window_id, get_TrxName());
}
// tabs
for (MTab tab : window.getTabs(true, get_TrxName())) {
int asp_tab_id = DB.getSQLValueEx(get_TrxName(),
"SELECT ASP_Tab_ID FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?",
asp_window_id, tab.getAD_Tab_ID());
X_ASP_Tab aspTab = null;
if (asp_tab_id < 1) {
aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName());
aspTab.setASP_Window_ID(asp_window_id);
aspTab.setAD_Tab_ID(tab.getAD_Tab_ID());
aspTab.setASP_Status(p_ASP_Status);
aspTab.setAllFields(! p_IsGenerateFields);
if (aspTab.save()) {
noTabs++;
asp_tab_id = aspTab.getASP_Tab_ID();
}
} else {
aspTab = new X_ASP_Tab(getCtx(), asp_tab_id, get_TrxName());
}
// fields
for (MField field : tab.getFields(true, get_TrxName())) {
if (p_IsGenerateFields) {
if (DB.getSQLValueEx(
get_TrxName(),
"SELECT COUNT(*) FROM ASP_Field WHERE ASP_Tab_ID = ? AND AD_Field_ID = ?",
aspTab.getASP_Tab_ID(), field.getAD_Field_ID()) < 1) {
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());
if (column.getAD_Reference_ID() == DisplayType.Button) {
if (column.getAD_Process_ID() > 0) {
generateProcess(column.getAD_Process_ID());
}
}
}
}
} else if (menu.getAction().equals(MMenu.ACTION_Process)
|| menu.getAction().equals(MMenu.ACTION_Report)) {
generateWindow(menu.getAD_Window_ID());
} else if (menu.getAction().equals(MMenu.ACTION_Process) || menu.getAction().equals(MMenu.ACTION_Report)) {
generateProcess(menu.getAD_Process_ID());
} else if (menu.getAction().equals(MMenu.ACTION_Form)) {
// Add Form
MForm form = new MForm(getCtx(), menu.getAD_Form_ID(), get_TrxName());
if (DB.getSQLValueEx(
get_TrxName(),
"SELECT COUNT(*) FROM ASP_Form WHERE ASP_Level_ID = ? AND AD_Form_ID = ?",
p_ASP_Level_ID, form.getAD_Form_ID()) < 1) {
X_ASP_Form aspForm = new X_ASP_Form(getCtx(), 0, get_TrxName());
aspForm.setASP_Level_ID(p_ASP_Level_ID);
aspForm.setAD_Form_ID(form.getAD_Form_ID());
aspForm.setASP_Status(p_ASP_Status);
if (aspForm.save())
noForms++;
}
generateForm(menu.getAD_Form_ID());
} else if (menu.getAction().equals(MMenu.ACTION_Task)) {
// Add Task
MTask task = new MTask(getCtx(), menu.getAD_Task_ID(), get_TrxName());
if (DB.getSQLValueEx(
get_TrxName(),
"SELECT COUNT(*) FROM ASP_Task WHERE ASP_Level_ID = ? AND AD_Task_ID = ?",
p_ASP_Level_ID, task.getAD_Task_ID()) < 1) {
X_ASP_Task aspTask = new X_ASP_Task(getCtx(), 0, get_TrxName());
aspTask.setASP_Level_ID(p_ASP_Level_ID);
aspTask.setAD_Task_ID(task.getAD_Task_ID());
aspTask.setASP_Status(p_ASP_Status);
if (aspTask.save())
noTasks++;
}
generateTask(menu.getAD_Task_ID());
} else if (menu.getAction().equals(MMenu.ACTION_WorkFlow)) {
generateWorkflow(menu.getAD_Workflow_ID());
}
@ -291,6 +208,9 @@ public class ASPGenerateLevel extends SvrProcess
if (process.getAD_Workflow_ID() > 0) {
generateWorkflow(process.getAD_Workflow_ID());
}
if (process.getAD_Form_ID() > 0) {
generateForm(process.getAD_Form_ID());
}
}
private void generateWorkflow(int p_AD_Workflow_ID) {
@ -307,6 +227,121 @@ public class ASPGenerateLevel extends SvrProcess
if (aspWorkflow.save())
noWorkflows++;
}
for (MWFNode node : workflow.getNodes(false, getAD_Client_ID())) {
if ( ( MWFNode.ACTION_AppsProcess.equals(node.getAction()) || MWFNode.ACTION_AppsReport.equals(node.getAction()) ) && node.getAD_Process_ID() > 0) {
generateProcess(node.getAD_Process_ID());
} else if (MWFNode.ACTION_AppsTask.equals(node.getAction()) && node.getAD_Task_ID() > 0) {
generateTask(node.getAD_Task_ID());
} else if (MWFNode.ACTION_UserForm.equals(node.getAction()) && node.getAD_Form_ID() > 0) {
generateForm(node.getAD_Form_ID());
} else if (MWFNode.ACTION_UserWindow.equals(node.getAction()) && node.getAD_Window_ID() > 0) {
generateWindow(node.getAD_Window_ID());
}
}
}
private void generateForm(int p_AD_Form_ID) {
// Add Form
MForm form = new MForm(getCtx(), p_AD_Form_ID, get_TrxName());
if (DB.getSQLValueEx(
get_TrxName(),
"SELECT COUNT(*) FROM ASP_Form WHERE ASP_Level_ID = ? AND AD_Form_ID = ?",
p_ASP_Level_ID, form.getAD_Form_ID()) < 1) {
X_ASP_Form aspForm = new X_ASP_Form(getCtx(), 0, get_TrxName());
aspForm.setASP_Level_ID(p_ASP_Level_ID);
aspForm.setAD_Form_ID(form.getAD_Form_ID());
aspForm.setASP_Status(p_ASP_Status);
if (aspForm.save())
noForms++;
}
}
private void generateTask(int p_AD_Task_ID) {
// Add Task
MTask task = new MTask(getCtx(), p_AD_Task_ID, get_TrxName());
if (DB.getSQLValueEx(
get_TrxName(),
"SELECT COUNT(*) FROM ASP_Task WHERE ASP_Level_ID = ? AND AD_Task_ID = ?",
p_ASP_Level_ID, task.getAD_Task_ID()) < 1) {
X_ASP_Task aspTask = new X_ASP_Task(getCtx(), 0, get_TrxName());
aspTask.setASP_Level_ID(p_ASP_Level_ID);
aspTask.setAD_Task_ID(task.getAD_Task_ID());
aspTask.setASP_Status(p_ASP_Status);
if (aspTask.save())
noTasks++;
}
}
private void generateWindow(int p_AD_Window_ID) {
MWindow window = new MWindow(getCtx(), p_AD_Window_ID, get_TrxName());
int asp_window_id = DB.getSQLValueEx(get_TrxName(),
"SELECT ASP_Window_ID FROM ASP_Window WHERE ASP_Level_ID = ? AND AD_Window_ID = ?",
p_ASP_Level_ID, window.getAD_Window_ID());
X_ASP_Window aspWindow = null;
if (asp_window_id < 1) {
// Add Window, Tabs and Fields (if IsGenerateFields)
aspWindow = new X_ASP_Window(getCtx(), 0, get_TrxName());
aspWindow.setASP_Level_ID(p_ASP_Level_ID);
aspWindow.setAD_Window_ID(window.getAD_Window_ID());
aspWindow.setASP_Status(p_ASP_Status);
if (aspWindow.save()) {
noWindows++;
asp_window_id = aspWindow.getASP_Window_ID();
}
} else {
aspWindow = new X_ASP_Window(getCtx(), asp_window_id, get_TrxName());
}
// tabs
for (MTab tab : window.getTabs(true, get_TrxName())) {
int asp_tab_id = DB.getSQLValueEx(get_TrxName(),
"SELECT ASP_Tab_ID FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?",
asp_window_id, tab.getAD_Tab_ID());
X_ASP_Tab aspTab = null;
if (asp_tab_id < 1) {
aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName());
aspTab.setASP_Window_ID(asp_window_id);
aspTab.setAD_Tab_ID(tab.getAD_Tab_ID());
aspTab.setASP_Status(p_ASP_Status);
aspTab.setAllFields(! p_IsGenerateFields);
if (aspTab.save()) {
noTabs++;
asp_tab_id = aspTab.getASP_Tab_ID();
}
} else {
aspTab = new X_ASP_Tab(getCtx(), asp_tab_id, get_TrxName());
}
if (tab.getAD_Process_ID() > 0) {
generateProcess(tab.getAD_Process_ID());
}
for (MToolBarButton tb : MToolBarButton.getProcessButtonOfTab(tab.getAD_Tab_ID(), get_TrxName())) {
if (tb.getAD_Process_ID() > 0) {
generateProcess(tb.getAD_Process_ID());
}
}
// fields
for (MField field : tab.getFields(true, get_TrxName())) {
if (p_IsGenerateFields) {
if (DB.getSQLValueEx(
get_TrxName(),
"SELECT COUNT(*) FROM ASP_Field WHERE ASP_Tab_ID = ? AND AD_Field_ID = ?",
aspTab.getASP_Tab_ID(), field.getAD_Field_ID()) < 1) {
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());
if (column.getAD_Reference_ID() == DisplayType.Button) {
if (column.getAD_Process_ID() > 0) {
generateProcess(column.getAD_Process_ID());
}
}
}
}
}
} // ASPGenerateLevel

View File

@ -131,8 +131,10 @@ implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Set the definite document number after completed (if needed)
//setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -156,9 +158,6 @@ implements DocAction
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
//setDefiniteDocumentNo();
setProcessed(true);
setDocAction(DOCACTION_Close);

View File

@ -194,8 +194,10 @@ implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Set the definite document number after completed (if needed)
//setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -223,9 +225,6 @@ implements DocAction
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
//setDefiniteDocumentNo();
setProcessed(true);
setDocAction(DOCACTION_Close);

View File

@ -1256,6 +1256,9 @@ public class MInOut extends X_M_InOut implements DocAction
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -1652,9 +1655,6 @@ public class MInOut extends X_M_InOut implements DocAction
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = info.toString();
setProcessed(true);
setDocAction(DOCACTION_Close);

View File

@ -390,6 +390,9 @@ public class MInventory extends X_M_Inventory implements DocAction
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -579,9 +582,6 @@ public class MInventory extends X_M_Inventory implements DocAction
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
//
setProcessed(true);
setDocAction(DOCACTION_Close);

View File

@ -1692,6 +1692,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -2086,9 +2089,6 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
// Counter Documents
MInvoice counter = createCounterDoc();
if (counter != null)
@ -2120,7 +2120,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
setDateInvoiced(new Timestamp (System.currentTimeMillis()));
if (getDateAcct().before(getDateInvoiced())) {
setDateAcct(getDateInvoiced());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());
}
}
if (dt.isOverwriteSeqOnComplete()) {

View File

@ -593,7 +593,10 @@ public class MJournal extends X_GL_Journal implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -610,9 +613,6 @@ public class MJournal extends X_GL_Journal implements DocAction
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
//
setProcessed(true);
setDocAction(DOCACTION_Close);

View File

@ -438,7 +438,10 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -494,9 +497,6 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
//
setProcessed(true);
setDocAction(DOCACTION_Close);

View File

@ -353,7 +353,10 @@ public class MMovement extends X_M_Movement implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -531,9 +534,6 @@ public class MMovement extends X_M_Movement implements DocAction
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
//
setProcessed(true);

View File

@ -1869,6 +1869,10 @@ public class MOrder extends X_C_Order implements DocAction
setProcessed(false);
return DocAction.STATUS_InProgress;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
// Offers
if (MDocType.DOCSUBTYPESO_Proposal.equals(DocSubTypeSO)
|| MDocType.DOCSUBTYPESO_Quotation.equals(DocSubTypeSO))
@ -1882,8 +1886,6 @@ public class MOrder extends X_C_Order implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
setProcessed(true);
return DocAction.STATUS_Completed;
}
@ -1986,9 +1988,6 @@ public class MOrder extends X_C_Order implements DocAction
return DocAction.STATUS_Invalid;
}
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
setProcessed(true);
m_processMsg = info.toString();
@ -2130,7 +2129,7 @@ public class MOrder extends X_C_Order implements DocAction
setDateOrdered(new Timestamp (System.currentTimeMillis()));
if (getDateAcct().before(getDateOrdered())) {
setDateAcct(getDateOrdered());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());
}
}
}

View File

@ -1943,7 +1943,10 @@ public class MPayment extends X_C_Payment
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -2077,9 +2080,6 @@ public class MPayment extends X_C_Payment
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
//
setProcessed(true);

View File

@ -415,6 +415,9 @@ public class MProduction extends X_M_Production implements DocAction {
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
// Std Period open?
MPeriod.testPeriodOpen(getCtx(), getMovementDate(), MDocType.DOCBASETYPE_MaterialProduction, getAD_Org_ID());
if ( getIsCreated().equals("N") )
{
m_processMsg = "Not created";

View File

@ -430,6 +430,9 @@ public class MRMA extends X_M_RMA implements DocAction
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -461,9 +464,6 @@ public class MRMA extends X_M_RMA implements DocAction
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
//
setProcessed(true);
setDocAction(DOCACTION_Close);

View File

@ -331,6 +331,9 @@ public class MRequisition extends X_M_Requisition implements DocAction
return status;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -348,9 +351,6 @@ public class MRequisition extends X_M_Requisition implements DocAction
return DocAction.STATUS_Invalid;
}
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
//
setProcessed(true);
setDocAction(ACTION_Close);

View File

@ -2551,6 +2551,8 @@ public final class MRole extends X_AD_Role
+ " WHERE ro.AD_Role_ID=?"
+ " AND ty.DocBaseType=?"
+ (MDocType.DOCBASETYPE_SalesOrder.equals(doc.getDocBaseType()) ? " AND ty.DocSubTypeSO=?" : "")
+ (MDocType.DOCBASETYPE_PurchaseOrder.equals(doc.getDocBaseType()) && doc.getDocSubTypeSO() != null ? " AND ty.DocSubTypeSO=?" : "")
+ (MDocType.DOCBASETYPE_MaterialPhysicalInventory.equals(doc.getDocBaseType()) ? " AND ty.DocSubTypeInv=?" : "")
+ " AND rl.Value IN ("
+ sql_values
+ ")";
@ -2560,6 +2562,10 @@ public final class MRole extends X_AD_Role
pstmt.setString(idxpar++, doc.getDocBaseType());
if (MDocType.DOCBASETYPE_SalesOrder.equals(doc.getDocBaseType()))
pstmt.setString(idxpar++, doc.getDocSubTypeSO());
else if (MDocType.DOCBASETYPE_PurchaseOrder.equals(doc.getDocBaseType()) && doc.getDocSubTypeSO() != null)
pstmt.setString(idxpar++, doc.getDocSubTypeSO());
else if (MDocType.DOCBASETYPE_MaterialPhysicalInventory.equals(doc.getDocBaseType()))
pstmt.setString(idxpar++, doc.getDocSubTypeInv());
} else {
// master role on tenant - check options based on doctypeid
sql = "SELECT DISTINCT rl.Value, a.IsActive"

View File

@ -540,15 +540,18 @@ public class MTable extends X_AD_Table
// boolean hasParents = false;
StringBuffer constraints = new StringBuffer();
getColumns(true);
boolean columnAdded = false;
for (int i = 0; i < m_columns.length; i++)
{
MColumn column = m_columns[i];
String colSQL = column.getSQLDDL();
if ( colSQL != null )
{
if (i > 0)
if (columnAdded)
sb.append(", ");
sb.append(column.getSQLDDL());
else
columnAdded = true;
sb.append(column.getSQLDDL());
}
else // virtual column
continue;

View File

@ -216,6 +216,8 @@ public class DocActionTemplate extends PO implements DocAction
return status;
}
// setDefiniteDocumentNo();
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@ -233,8 +235,6 @@ public class DocActionTemplate extends PO implements DocAction
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
// setDefiniteDocumentNo();
// setProcessed(true);
// setDocAction(DOCACTION_Close);
return DocAction.STATUS_Completed;
@ -248,6 +248,10 @@ public class DocActionTemplate extends PO implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) {
setDateInvoiced(new Timestamp (System.currentTimeMillis()));
if (getDateAcct().before(getDateInvoiced())) {
setDateAcct(getDateInvoiced());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());
}
}
if (dt.isOverwriteSeqOnComplete()) {
String value = null;

View File

@ -25,10 +25,13 @@
* *
* Sponsors: *
* - e-Evolution (http://www.e-evolution.com) *
***********************************************************************/
**********************************************************************/
package org.adempiere.model;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.process.rpl.exp.ExportHelper;
@ -39,6 +42,7 @@ import org.compiere.model.MTable;
import org.compiere.model.ModelValidationEngine;
import org.compiere.model.ModelValidator;
import org.compiere.model.PO;
import org.compiere.model.Query;
import org.compiere.model.X_AD_ReplicationDocument;
import org.compiere.model.X_AD_ReplicationTable;
import org.compiere.util.CLogger;
@ -61,151 +65,186 @@ import org.compiere.util.Env;
*
* @version $Id$
*/
public class ExportModelValidator implements ModelValidator
{
/** Context variable which says if replication is enabled */
public class ExportModelValidator implements ModelValidator {
/** Context variable which says if replication is enabled */
public static final String CTX_IsReplicationEnabled = "#IsReplicationEnabled";
/** Logger */
private static CLogger log = CLogger.getCLogger(ExportModelValidator.class);
/** Client */
private int m_AD_Client_ID = -1;
/** Organization */
private int m_AD_Org_ID = -1;
/** Role */
private int m_AD_Role_ID = -1;
/** User */
private int m_AD_User_ID = -1;
/** Replication Strategy **/
private int m_AD_ReplicationStrategy_ID = -1;
/** ModelValidationEngine engine **/
ModelValidationEngine m_engine = null;
/** Export Helper */
ExportHelper expHelper = null;
List<String> modelTables = new ArrayList<String>();
List<String> docTables = new ArrayList<String>();
/* The Export Helpers per each replication strategy */
Hashtable<Integer, ExportHelper> helpers = new Hashtable<Integer, ExportHelper>();
/**
* Constructor.
* The class is instantiated when logging in and client is selected/known
*/
public ExportModelValidator ()
{
public ExportModelValidator () {
super ();
}
/**
* Initialize Validation
* @param engine validation engine
* @param engine validation engine
* @param client client
*/
public void initialize (ModelValidationEngine engine, MClient client)
{
m_engine = engine;
if (client != null)
{
public void initialize (ModelValidationEngine engine, MClient client) {
if (client != null) {
m_AD_Client_ID = client.getAD_Client_ID();
if (log.isLoggable(Level.INFO)) log.info(client.toString());
}
else
{
log.warning("Export Model Validator cannot be used as a global validator, it needs to be defined in a per-client (tenant) basis");
return;
}
loadReplicationStrategy(engine);
} else {
log.warning("Export Model Validator cannot be used as a global validator, it needs to be defined in a per-client (tenant) basis");
return;
}
}
/**
* Model Change of a monitored Table.
* Called after PO.beforeSave/PO.beforeDelete
* @param po persistent object
* @param type TYPE_
* @return error message or null
* @exception Exception if the recipient wishes the change to be not accept.
*/
public String modelChange (PO po, int type) throws Exception
{
//String Mode = "Table";
if (log.isLoggable(Level.INFO)) log.info("po.get_TableName() = " + po.get_TableName());
if (expHelper != null) {
if ( type == TYPE_AFTER_CHANGE
|| type == TYPE_AFTER_NEW
|| type == TYPE_BEFORE_DELETE) // After Change or After New
{
X_AD_ReplicationTable replicationTable = MReplicationStrategy.getReplicationTable(
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID());
if (replicationTable != null)
{
expHelper.exportRecord(
po,
MReplicationStrategy.REPLICATION_TABLE,
replicationTable.getReplicationType(),
type);
}
}
public void loadReplicationStrategy(ModelValidationEngine engine) {
MClient client = MClient.get(Env.getCtx(), m_AD_Client_ID);
String where = "AD_ReplicationStrategy_ID IN (" +
"SELECT AD_ReplicationStrategy_ID FROM AD_Client WHERE AD_Client_ID=? " +
"UNION " +
"SELECT AD_ReplicationStrategy_ID FROM AD_Org WHERE AD_Client_ID=?)";
List<MReplicationStrategy> rss = new Query(Env.getCtx(), MReplicationStrategy.Table_Name, where, null)
.setOnlyActiveRecords(true)
.setParameters(m_AD_Client_ID, m_AD_Client_ID)
.list();
for (MReplicationStrategy rplStrategy : rss) {
ExportHelper expClientHelper = new ExportHelper(client, rplStrategy);
helpers.put(rplStrategy.getAD_ReplicationStrategy_ID(), expClientHelper);
// Add Tables
// We want to be informed when records in Replication tables are created/updated/deleted!
for (X_AD_ReplicationTable rplTable : rplStrategy.getReplicationTables()) {
if ( X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType())
|| X_AD_ReplicationTable.REPLICATIONTYPE_Broadcast.equals(rplTable.getReplicationType())
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType()))
{
String tableName = MTable.getTableName(client.getCtx(), rplTable.getAD_Table_ID());
if (! modelTables.contains(tableName)) {
engine.addModelChange(tableName, this);
modelTables.add(tableName);
}
}
}
// Add Documents
// We want to be informed when Replication documents are created/updated/deleted!
for (X_AD_ReplicationDocument rplDocument : rplStrategy.getReplicationDocuments()) {
if ( X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType())
|| X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType()))
{
String tableName = MTable.getTableName(client.getCtx(), rplDocument.getAD_Table_ID());
if (! docTables.contains(tableName)) {
engine.addDocValidate(tableName, this);
docTables.add(tableName);
}
}
}
}
}
/**
* Model Change of a monitored Table.
* Called after PO.beforeSave/PO.beforeDelete
* @param po persistent object
* @param type TYPE_
* @return error message or null
* @exception Exception if the recipient wishes the change to be not accept.
*/
public String modelChange (PO po, int type) throws Exception {
if (log.isLoggable(Level.INFO)) log.info("po.get_TableName() = " + po.get_TableName());
int rsID = getReplicationStrategy(po);
if (rsID > 0) {
ExportHelper expHelper = helpers.get(rsID);
if (expHelper != null) {
if ( type == TYPE_AFTER_CHANGE
|| type == TYPE_AFTER_NEW
|| type == TYPE_BEFORE_DELETE) {
X_AD_ReplicationTable replicationTable = MReplicationStrategy.getReplicationTable(
po.getCtx(), rsID, po.get_Table_ID());
if (replicationTable != null) {
expHelper.exportRecord(
po,
MReplicationStrategy.REPLICATION_TABLE,
replicationTable.getReplicationType(),
type);
}
}
}
}
return null;
}
/**
* Validate Document.
* Called as first step of DocAction.prepareIt
* when you called addDocValidate for the table.
* Called as first step of DocAction.prepareIt
* when you called addDocValidate for the table.
* @param po persistent object
* @param type see TIMING_ constants
* @return error message or null
* @throws Exception
* @return error message or null
* @throws Exception
*/
public String docValidate (PO po, int type)
{
public String docValidate (PO po, int type) {
if (log.isLoggable(Level.INFO)) log.info("Replicate the Document = " + po.get_TableName() + " with Type = " + type);
String result = null;
if (expHelper != null) {
try {
if ( type == TIMING_AFTER_COMPLETE
|| type == TIMING_AFTER_CLOSE
|| type == TIMING_AFTER_REVERSECORRECT
|| type == TIMING_AFTER_VOID
|| type == TIMING_AFTER_REACTIVATE
//|| type == TIMING_AFTER_PREPARE
)
{
X_AD_ReplicationDocument replicationDocument = null;
int C_DocType_ID = po.get_ValueAsInt("C_DocType_ID");
if (C_DocType_ID > 0)
{
replicationDocument = MReplicationStrategy.getReplicationDocument(
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID(), C_DocType_ID);
}
else
{
replicationDocument = MReplicationStrategy.getReplicationDocument(
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID());
}
if (replicationDocument != null) {
expHelper.exportRecord(
po,
MReplicationStrategy.REPLICATION_DOCUMENT,
replicationDocument.getReplicationType(),
type);
}
int rsID = getReplicationStrategy(po);
if (rsID > 0) {
ExportHelper expHelper = helpers.get(rsID);
if (expHelper != null) {
try {
if ( type == TIMING_AFTER_COMPLETE
|| type == TIMING_AFTER_CLOSE
|| type == TIMING_AFTER_REVERSECORRECT
|| type == TIMING_AFTER_VOID
|| type == TIMING_AFTER_REACTIVATE
//|| type == TIMING_AFTER_PREPARE
) {
X_AD_ReplicationDocument replicationDocument = null;
int C_DocType_ID = po.get_ValueAsInt("C_DocType_ID");
if (C_DocType_ID > 0) {
replicationDocument = MReplicationStrategy.getReplicationDocument(
po.getCtx(), rsID, po.get_Table_ID(), C_DocType_ID);
} else {
replicationDocument = MReplicationStrategy.getReplicationDocument(
po.getCtx(), rsID, po.get_Table_ID());
}
if (replicationDocument != null) {
expHelper.exportRecord(
po,
MReplicationStrategy.REPLICATION_DOCUMENT,
replicationDocument.getReplicationType(),
type);
}
}
} catch (Exception e) {
e.printStackTrace();
result = e.toString();
}
} catch (Exception e) {
e.printStackTrace();
result = e.toString();
}
}
return result;
}
private int getReplicationStrategy(PO po) {
int rsID = -1;
int orgID = po.getAD_Org_ID();
if (orgID > 0) {
rsID = MOrg.get(po.getCtx(), orgID).getAD_ReplicationStrategy_ID();
}
if (rsID <= 0) {
int clientID = po.getAD_Client_ID();
rsID = MClient.get(Env.getCtx(), clientID).getAD_ReplicationStrategy_ID();
}
return rsID;
}
/**
* User Login.
* Called when preferences are set
@ -214,91 +253,26 @@ public class ExportModelValidator implements ModelValidator
* @param AD_User_ID user
* @return error message or null
*/
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
{
Env.setContext(Env.getCtx(), CTX_IsReplicationEnabled, true);
m_AD_Org_ID = AD_Org_ID;
m_AD_Role_ID = AD_Role_ID;
m_AD_User_ID = AD_User_ID;
if (log.isLoggable(Level.INFO)){
log.info("AD_Org_ID =" + m_AD_Org_ID);
log.info("AD_Role_ID =" + m_AD_Role_ID);
log.info("AD_User_ID =" + m_AD_User_ID);}
loadReplicationStrategy();
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID) {
Env.setContext(Env.getCtx(), CTX_IsReplicationEnabled, true);
return null;
}
/**
* Get Client to be monitored
* @return AD_Client_ID client
*/
public int getAD_Client_ID()
{
public int getAD_Client_ID() {
return m_AD_Client_ID;
}
public void loadReplicationStrategy()
{
MClient client = MClient.get(Env.getCtx(), m_AD_Client_ID);
MReplicationStrategy rplStrategy = null;
m_AD_ReplicationStrategy_ID = MOrg.get(client.getCtx(),m_AD_Org_ID).getAD_ReplicationStrategy_ID();
if(m_AD_ReplicationStrategy_ID <= 0)
{
m_AD_ReplicationStrategy_ID = client.getAD_ReplicationStrategy_ID();
if (log.isLoggable(Level.INFO)) log.info("client.getAD_ReplicationStrategy_ID() = " + m_AD_ReplicationStrategy_ID);
}
if (m_AD_ReplicationStrategy_ID > 0) {
rplStrategy = new MReplicationStrategy(client.getCtx(), m_AD_ReplicationStrategy_ID, null);
if(!rplStrategy.isActive())
{
return;
}
expHelper = new ExportHelper(client, rplStrategy);
}
// Add Tables
// We want to be informed when records in Replication tables are created/updated/deleted!
//engine.addModelChange(MBPartner.Table_Name, this);
//engine.addModelChange(MOrder.Table_Name, this);
//engine.addModelChange(MOrderLine.Table_Name, this);
if (rplStrategy != null) {
for (X_AD_ReplicationTable rplTable : rplStrategy.getReplicationTables()) {
if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType())
|| X_AD_ReplicationTable.REPLICATIONTYPE_Broadcast.equals(rplTable.getReplicationType())
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType()))
{
String tableName = MTable.getTableName(client.getCtx(), rplTable.getAD_Table_ID());
m_engine.addModelChange(tableName, this);
}
}
}
// Add Documents
// We want to be informed when Replication documents are created/updated/deleted!
if (rplStrategy != null) {
for (X_AD_ReplicationDocument rplDocument : rplStrategy.getReplicationDocuments()) {
if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType())
|| X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType()))
{
String tableName = MTable.getTableName(client.getCtx(), rplDocument.getAD_Table_ID());
m_engine.addDocValidate(tableName, this);
}
}
}
}
/**
* String Representation
* @return info
*/
public String toString ()
{
public String toString () {
StringBuilder sb = new StringBuilder (ExportModelValidator.class.getName());
return sb.toString();
}
}

View File

@ -34,6 +34,10 @@ import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv;
import org.compiere.apps.ConfirmPanel;
import org.compiere.model.GridTab;
import org.compiere.model.MAllocationHdr;
import org.compiere.model.MBankStatement;
import org.compiere.model.MDocType;
import org.compiere.model.MProduction;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.process.DocOptions;
@ -245,6 +249,15 @@ public class VDocAction extends CDialog
if(doctypeId==null || doctypeId.intValue()==0){
doctypeId = (Integer)m_mTab.getValue("C_DocTypeTarget_ID");
}
if (doctypeId == null && MAllocationHdr.Table_ID == m_AD_Table_ID) {
doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_PaymentAllocation);
}
if (doctypeId == null && MBankStatement.Table_ID == m_AD_Table_ID) {
doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_BankStatement);
}
if (doctypeId == null && MProduction.Table_ID == m_AD_Table_ID) {
doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_MaterialProduction);
}
if (log.isLoggable(Level.FINE)) log.fine("get doctype: " + doctypeId);
if (doctypeId != null) {
index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()),

View File

@ -111,8 +111,8 @@ public class ADSortTab extends Panel implements IADTabpanel
// UI variables
private Label noLabel = new Label();
private Label yesLabel = new Label();
private Button bAdd = ButtonFactory.createButton(null, ThemeManager.getThemeResource("images/MoveLeft16.png"), null);
private Button bRemove = ButtonFactory.createButton(null, ThemeManager.getThemeResource("images/MoveRight16.png"), null);
private Button bAdd = ButtonFactory.createButton(null, ThemeManager.getThemeResource("images/MoveRight16.png"), null);
private Button bRemove = ButtonFactory.createButton(null, ThemeManager.getThemeResource("images/MoveLeft16.png"), null);
private Button bUp = ButtonFactory.createButton(null, ThemeManager.getThemeResource("images/MoveUp16.png"), null);
private Button bDown = ButtonFactory.createButton(null, ThemeManager.getThemeResource("images/MoveDown16.png"), null);
//

View File

@ -107,9 +107,9 @@ public class CustomizeGridViewPanel extends Panel
private Label noLabel = new Label();
private Label yesLabel = new Label();
private Button bAdd = ButtonFactory.createButton(null,
ThemeManager.getThemeResource("images/MoveLeft16.png"), null);
private Button bRemove = ButtonFactory.createButton(null,
ThemeManager.getThemeResource("images/MoveRight16.png"), null);
private Button bRemove = ButtonFactory.createButton(null,
ThemeManager.getThemeResource("images/MoveLeft16.png"), null);
private Button bUp = ButtonFactory.createButton(null,
ThemeManager.getThemeResource("images/MoveUp16.png"), null);
private Button bDown = ButtonFactory.createButton(null,

View File

@ -35,7 +35,11 @@ import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridTab;
import org.compiere.model.MAllocationHdr;
import org.compiere.model.MBankStatement;
import org.compiere.model.MClientInfo;
import org.compiere.model.MDocType;
import org.compiere.model.MProduction;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.process.DocOptions;
@ -169,6 +173,15 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
if(doctypeId==null || doctypeId.intValue()==0){
doctypeId = (Integer)gridTab.getValue("C_DocTypeTarget_ID");
}
if (doctypeId == null && MAllocationHdr.Table_ID == m_AD_Table_ID) {
doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_PaymentAllocation);
}
if (doctypeId == null && MBankStatement.Table_ID == m_AD_Table_ID) {
doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_BankStatement);
}
if (doctypeId == null && MProduction.Table_ID == m_AD_Table_ID) {
doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_MaterialProduction);
}
if (logger.isLoggable(Level.FINE)) logger.fine("get doctype: " + doctypeId);
if (doctypeId != null) {
index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB