IDEMPIERE-4853 Process to copy a Packout definition (FHCA-859) (#756)

* IDEMPIERE-4853 Process to copy a Packout definition (FHCA-859)

* IDEMPIERE-4853 Process to copy a Packout definition (FHCA-859)

Do not copy inactive details (as suggested by hengsin)
This commit is contained in:
Carlos Ruiz 2021-07-01 16:14:46 +02:00 committed by GitHub
parent c4444bef5d
commit 0e58005d6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 190 additions and 4 deletions

View File

@ -0,0 +1,39 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-4853 Process to copy a Packout definition (FHCA-859)
-- Jun 30, 2021, 7:59:32 PM CEST
INSERT INTO AD_Process (AD_Process_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,IsReport,Value,IsDirectPrint,Classname,AccessLevel,EntityType,Statistic_Count,Statistic_Seconds,IsBetaFunctionality,ShowHelp,CopyFromProcess,AD_Process_UU,AllowMultipleExecution) VALUES (200133,0,0,'Y',TO_DATE('2021-06-30 19:59:31','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-30 19:59:31','YYYY-MM-DD HH24:MI:SS'),100,'Copy from Pack Out','Copy Package Details from another Pack Out','N','CopyFromPackOut','N','org.compiere.process.CopyFromPackOut','6','D',0,0,'N','Y','N','65392ae4-8a3e-4a6e-a4ca-e665102df00a','P')
;
-- Jun 30, 2021, 7:59:58 PM CEST
INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,AD_ToolBarButton_UU,Action,AD_Tab_ID,AD_Process_ID,SeqNo,EntityType) VALUES (0,0,TO_DATE('2021-06-30 19:59:57','YYYY-MM-DD HH24:MI:SS'),100,'CopyFromPackOut','Y',200113,'CopyFromPackOut',TO_DATE('2021-06-30 19:59:57','YYYY-MM-DD HH24:MI:SS'),100,'N','a4e828bd-7fd5-4aa0-acf1-ba5dc91891d8','W',50005,200133,10,'D')
;
-- Jun 30, 2021, 8:02:52 PM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200353,0,0,'Y',TO_DATE('2021-06-30 20:02:52','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-30 20:02:52','YYYY-MM-DD HH24:MI:SS'),100,'Package Exp.',200133,10,30,NULL,'N',22,'N','AD_Package_Exp_ID','Y','D',50018,'7130b395-15d3-4c42-a598-190704860f7e','N','N')
;
-- Jun 30, 2021, 8:03:01 PM CEST
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_DATE('2021-06-30 20:03:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200353
;
-- Jun 30, 2021, 8:34:36 PM CEST
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200151,'AD_Package_Exp_ID except the current','S','AD_Package_Exp.AD_Package_Exp_ID!=@AD_Package_Exp_ID@',0,0,'Y',TO_DATE('2021-06-30 20:34:35','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-30 20:34:35','YYYY-MM-DD HH24:MI:SS'),100,'D','c33608e1-4124-4ec4-9eb3-7144d7ebb45d')
;
-- Jun 30, 2021, 8:34:43 PM CEST
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200151,Updated=TO_DATE('2021-06-30 20:34:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200353
;
-- Jun 30, 2021, 8:51:25 PM CEST
UPDATE AD_Column SET DefaultValue='NULL',Updated=TO_DATE('2021-06-30 20:51:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=50106
;
-- Jun 30, 2021, 8:51:44 PM CEST
UPDATE AD_Column SET DefaultValue='NULL',Updated=TO_DATE('2021-06-30 20:51:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213804
;
SELECT register_migration_script('202106302004_IDEMPIERE-4853.sql') FROM dual
;

View File

@ -0,0 +1,36 @@
-- IDEMPIERE-4853 Process to copy a Packout definition (FHCA-859)
-- Jun 30, 2021, 7:59:32 PM CEST
INSERT INTO AD_Process (AD_Process_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,IsReport,Value,IsDirectPrint,Classname,AccessLevel,EntityType,Statistic_Count,Statistic_Seconds,IsBetaFunctionality,ShowHelp,CopyFromProcess,AD_Process_UU,AllowMultipleExecution) VALUES (200133,0,0,'Y',TO_TIMESTAMP('2021-06-30 19:59:31','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-30 19:59:31','YYYY-MM-DD HH24:MI:SS'),100,'Copy from Pack Out','Copy Package Details from another Pack Out','N','CopyFromPackOut','N','org.compiere.process.CopyFromPackOut','6','D',0,0,'N','Y','N','65392ae4-8a3e-4a6e-a4ca-e665102df00a','P')
;
-- Jun 30, 2021, 7:59:58 PM CEST
INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,AD_ToolBarButton_UU,"action",AD_Tab_ID,AD_Process_ID,SeqNo,EntityType) VALUES (0,0,TO_TIMESTAMP('2021-06-30 19:59:57','YYYY-MM-DD HH24:MI:SS'),100,'CopyFromPackOut','Y',200113,'CopyFromPackOut',TO_TIMESTAMP('2021-06-30 19:59:57','YYYY-MM-DD HH24:MI:SS'),100,'N','a4e828bd-7fd5-4aa0-acf1-ba5dc91891d8','W',50005,200133,10,'D')
;
-- Jun 30, 2021, 8:02:52 PM CEST
INSERT INTO AD_Process_Para (AD_Process_Para_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,AD_Process_ID,SeqNo,AD_Reference_ID,AD_Reference_Value_ID,IsRange,FieldLength,IsMandatory,ColumnName,IsCentrallyMaintained,EntityType,AD_Element_ID,AD_Process_Para_UU,IsEncrypted,IsAutocomplete) VALUES (200353,0,0,'Y',TO_TIMESTAMP('2021-06-30 20:02:52','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-30 20:02:52','YYYY-MM-DD HH24:MI:SS'),100,'Package Exp.',200133,10,30,NULL,'N',22,'N','AD_Package_Exp_ID','Y','D',50018,'7130b395-15d3-4c42-a598-190704860f7e','N','N')
;
-- Jun 30, 2021, 8:03:01 PM CEST
UPDATE AD_Process_Para SET IsMandatory='Y',Updated=TO_TIMESTAMP('2021-06-30 20:03:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200353
;
-- Jun 30, 2021, 8:34:36 PM CEST
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200151,'AD_Package_Exp_ID except the current','S','AD_Package_Exp.AD_Package_Exp_ID!=@AD_Package_Exp_ID@',0,0,'Y',TO_TIMESTAMP('2021-06-30 20:34:35','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-30 20:34:35','YYYY-MM-DD HH24:MI:SS'),100,'D','c33608e1-4124-4ec4-9eb3-7144d7ebb45d')
;
-- Jun 30, 2021, 8:34:43 PM CEST
UPDATE AD_Process_Para SET AD_Val_Rule_ID=200151,Updated=TO_TIMESTAMP('2021-06-30 20:34:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_Para_ID=200353
;
-- Jun 30, 2021, 8:51:25 PM CEST
UPDATE AD_Column SET DefaultValue='NULL',Updated=TO_TIMESTAMP('2021-06-30 20:51:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=50106
;
-- Jun 30, 2021, 8:51:44 PM CEST
UPDATE AD_Column SET DefaultValue='NULL',Updated=TO_TIMESTAMP('2021-06-30 20:51:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=213804
;
SELECT register_migration_script('202106302004_IDEMPIERE-4853.sql') FROM dual
;

View File

@ -0,0 +1,80 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* 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., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Carlos Ruiz (sponsored by FH) *
**********************************************************************/
package org.compiere.process;
import java.util.logging.Level;
import org.compiere.model.MPackageExp;
/**
* Copy Package Details from another Pack Out
*/
public class CopyFromPackOut extends SvrProcess {
/* Package Exp. */
private int p_AD_Package_Exp_ID = 0;
/**
* Prepare - e.g., get Parameters.
*/
@Override
protected void prepare() {
for (ProcessInfoParameter para : getParameter()) {
String name = para.getParameterName();
switch (name) {
case "AD_Package_Exp_ID":
p_AD_Package_Exp_ID = para.getParameterAsInt();
break;
default:
if (log.isLoggable(Level.INFO))
log.log(Level.INFO, "Custom Parameter: " + name + "=" + para.getInfo());
break;
}
}
}
/**
* Perform process.
*
* @return Message (clear text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
int to_AD_Package_Exp_ID = getRecord_ID();
if (log.isLoggable(Level.INFO))
log.info("From AD_Package_Exp_ID=" + p_AD_Package_Exp_ID + " to " + to_AD_Package_Exp_ID);
if (to_AD_Package_Exp_ID == 0)
throw new IllegalArgumentException("Target AD_Package_Exp_ID == 0");
if (p_AD_Package_Exp_ID == 0)
throw new IllegalArgumentException("Source AD_Package_Exp_ID == 0");
MPackageExp from = new MPackageExp(getCtx(), p_AD_Package_Exp_ID, get_TrxName());
MPackageExp to = new MPackageExp(getCtx(), to_AD_Package_Exp_ID, get_TrxName());
//
int no = to.copyDetailsFrom(from);
//
return "@Copied@=" + no;
} // doIt
} // CopyFromOrder

View File

@ -18,6 +18,7 @@
package org.compiere.model; package org.compiere.model;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -33,11 +34,10 @@ import org.compiere.util.DB;
*/ */
public class MPackageExp extends X_AD_Package_Exp public class MPackageExp extends X_AD_Package_Exp
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = -8923634972273479831L; private static final long serialVersionUID = -6295261491885604619L;
/** /**
* MPackageExp * MPackageExp
@ -76,4 +76,35 @@ public class MPackageExp extends X_AD_Package_Exp
return true; return true;
} // afterDelete } // afterDelete
/**
* @param from the source MPackageExp to copy the details
* @return
*/
public int copyDetailsFrom(MPackageExp from) {
int count = 0;
for (MPackageExpDetail fromDetail : from.getDetails()) {
MPackageExpDetail toDetail = new MPackageExpDetail(getCtx(), 0, get_TrxName());
PO.copyValues(fromDetail, toDetail, getAD_Client_ID(), getAD_Org_ID());
toDetail.setAD_Package_Exp_ID(getAD_Package_Exp_ID());
toDetail.saveEx();
count++;
}
return count;
} // copyDetailsFrom
/**
* Get the details of a packout definition
* @return array of details
*/
private List<MPackageExpDetail> getDetails() {
final String where = "AD_Package_Exp_ID=?";
final String orderBy = "Line, AD_Package_Exp_ID";
List<MPackageExpDetail> list = new Query(getCtx(), MPackageExpDetail.Table_Name, where, get_TrxName())
.setParameters(getAD_Package_Exp_ID())
.setOrderBy(orderBy)
.setOnlyActiveRecords(true)
.list();
return list;
}
} // MPackageExp } // MPackageExp