From d8d2972ba6d0b16806731f9586d9fdbefde805ed Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 5 Nov 2009 05:53:57 +0000 Subject: [PATCH] Implement [2892393] - Flexibilize DocumentEngine getValidActions https://sourceforge.net/tracker/?func=detail&aid=2892393&group_id=176962&atid=879335 --- base/src/org/compiere/process/DocOptions.java | 42 +++++++++++++++++++ .../src/org/compiere/grid/ed/VDocAction.java | 9 ++++ .../webui/panel/WDocActionPanel.java | 9 ++++ 3 files changed, 60 insertions(+) create mode 100644 base/src/org/compiere/process/DocOptions.java diff --git a/base/src/org/compiere/process/DocOptions.java b/base/src/org/compiere/process/DocOptions.java new file mode 100644 index 0000000000..ba5b021e21 --- /dev/null +++ b/base/src/org/compiere/process/DocOptions.java @@ -0,0 +1,42 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +package org.compiere.process; + + +/** + * Document Options Interface + * + * @author Carlos Ruiz + */ +public interface DocOptions +{ + /** + * Customize Valid Actions + * @param docStatus + * @param processing + * @param orderType + * @param isSOTrx + * @param AD_Table_ID + * @param docAction + * @param options + * @param index + * @return Number of valid options + */ + public int customizeValidActions (String docStatus, Object processing, + String orderType, String isSOTrx, int AD_Table_ID, String[] docAction, String[] options, int index); + +} // DocAction diff --git a/client/src/org/compiere/grid/ed/VDocAction.java b/client/src/org/compiere/grid/ed/VDocAction.java index cad8ca708c..03ba6972c9 100644 --- a/client/src/org/compiere/grid/ed/VDocAction.java +++ b/client/src/org/compiere/grid/ed/VDocAction.java @@ -34,6 +34,9 @@ import org.compiere.apps.ADialog; import org.compiere.apps.AEnv; import org.compiere.apps.ConfirmPanel; import org.compiere.model.GridTab; +import org.compiere.model.MTable; +import org.compiere.model.PO; +import org.compiere.process.DocOptions; import org.compiere.process.DocumentEngine; import org.compiere.swing.CComboBox; import org.compiere.swing.CDialog; @@ -232,6 +235,12 @@ public class VDocAction extends CDialog index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options); + MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID); + PO po = table.getPO(Record_ID, null); + if (po instanceof DocOptions) + index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx, + m_AD_Table_ID, docActionHolder, options, index); + Integer doctypeId = (Integer)m_mTab.getValue("C_DocType_ID"); if(doctypeId==null || doctypeId.intValue()==0){ doctypeId = (Integer)m_mTab.getValue("C_DocTypeTarget_ID"); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java index db4cb2b78e..4da7aa865a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java @@ -29,6 +29,9 @@ import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Window; import org.adempiere.webui.window.FDialog; import org.compiere.model.GridTab; +import org.compiere.model.MTable; +import org.compiere.model.PO; +import org.compiere.process.DocOptions; import org.compiere.process.DocumentEngine; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -150,6 +153,12 @@ public class WDocActionPanel extends Window implements EventListener index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options); + MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID); + PO po = table.getPO(gridTab.getRecord_ID(), null); + if (po instanceof DocOptions) + index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx, + m_AD_Table_ID, docActionHolder, options, index); + Integer doctypeId = (Integer)gridTab.getValue("C_DocType_ID"); if(doctypeId==null || doctypeId.intValue()==0){ doctypeId = (Integer)gridTab.getValue("C_DocTypeTarget_ID");