IDEMPIERE-5082 Drop Shipment: Pass shipper and tracking number from MR to Customer Shipment (#1284)

This commit is contained in:
hengsin 2022-05-05 05:05:54 +08:00 committed by GitHub
parent c648eafa05
commit e91aa9d0d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 283 additions and 4 deletions

View File

@ -0,0 +1,106 @@
-- IDEMPIERE-5082 Drop Shipment: Pass shipper and tracking number from MR to Customer Shipment
SELECT register_migration_script('202204071051_IDEMPIERE-5082.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Apr 7, 2022, 10:51:05 AM MYT
UPDATE AD_Field SET DisplayLogic='@MovementType@=''C-'' |@IsDropShip@=''Y''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:51:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3495
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=55426
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=55427
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=55425
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=55428
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=6882
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=4248
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=4249
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=7804
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=7802
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=7803
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=7805
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=7801
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=370,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=7800
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=380,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=3482
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=390,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10347
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=400,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=9236
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=410,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=9235
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=420,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=3505
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=430,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=3506
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=440,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10531
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=450,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=5146
;
-- Apr 7, 2022, 10:55:15 AM MYT
UPDATE AD_Field SET DisplayLogic='@IsDropShip@=''Y''&@DeliveryViaRule@=''Y''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsDisplayedGrid='Y', SeqNoGrid=290, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:55:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6882
;
-- Apr 7, 2022, 10:56:51 AM MYT
UPDATE AD_Field SET DisplayLogic='@IsDropShip@=''Y''&@DeliveryViaRule@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:56:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6882
;
-- Apr 7, 2022, 10:57:20 AM MYT
UPDATE AD_Field SET DisplayLogic='@DeliveryViaRule@=''S'' &@IsDropShip@=''Y''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:57:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3504
;

View File

@ -0,0 +1,10 @@
-- IDEMPIERE-5082 Drop Shipment: Pass shipper and tracking number from MR to Customer Shipment
SELECT register_migration_script('202204071450_IDEMPIERE-5082.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Apr 7, 2022, 2:50:38 PM MYT
UPDATE AD_Field SET DisplayLogic=NULL, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 14:50:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3444
;

View File

@ -0,0 +1,103 @@
-- IDEMPIERE-5082 Drop Shipment: Pass shipper and tracking number from MR to Customer Shipment
SELECT register_migration_script('202204071051_IDEMPIERE-5082.sql') FROM dual;
-- Apr 7, 2022, 10:51:05 AM MYT
UPDATE AD_Field SET DisplayLogic='@MovementType@=''C-'' |@IsDropShip@=''Y''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:51:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3495
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=55426
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=55427
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=55425
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=55428
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=6882
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=4248
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=4249
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=7804
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=7802
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=7803
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=7805
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=7801
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=370,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=7800
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=380,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=3482
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=390,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10347
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=400,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=9236
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=410,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=9235
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=420,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=3505
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=430,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=3506
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=440,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10531
;
-- Apr 7, 2022, 10:53:06 AM MYT
UPDATE AD_Field SET SeqNo=450,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=5146
;
-- Apr 7, 2022, 10:55:15 AM MYT
UPDATE AD_Field SET DisplayLogic='@IsDropShip@=''Y''&@DeliveryViaRule@=''Y''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsDisplayedGrid='Y', SeqNoGrid=290, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:55:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6882
;
-- Apr 7, 2022, 10:56:51 AM MYT
UPDATE AD_Field SET DisplayLogic='@IsDropShip@=''Y''&@DeliveryViaRule@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:56:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6882
;
-- Apr 7, 2022, 10:57:20 AM MYT
UPDATE AD_Field SET DisplayLogic='@DeliveryViaRule@=''S'' &@IsDropShip@=''Y''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 10:57:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3504
;

View File

@ -0,0 +1,7 @@
-- IDEMPIERE-5082 Drop Shipment: Pass shipper and tracking number from MR to Customer Shipment
SELECT register_migration_script('202204071450_IDEMPIERE-5082.sql') FROM dual;
-- Apr 7, 2022, 2:50:38 PM MYT
UPDATE AD_Field SET DisplayLogic=NULL, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2022-04-07 14:50:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3444
;

View File

@ -48,7 +48,10 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
import org.compiere.util.Trx;
import org.compiere.util.TrxEventListener;
import org.compiere.util.Util;
import org.compiere.wf.MWFActivity;
/**
* Shipment Model
@ -1850,7 +1853,30 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
// Drop Shipments
MInOut dropShipment = createDropShipment();
if (dropShipment != null)
{
info.append(" - @DropShipment@: @M_InOut_ID@=").append(dropShipment.getDocumentNo());
ProcessInfo pi = MWFActivity.getCurrentWorkflowProcessInfo();
if (pi != null)
{
Trx.get(get_TrxName(), false).addTrxEventListener(new TrxEventListener() {
@Override
public void afterRollback(Trx trx, boolean success) {
trx.removeTrxEventListener(this);
}
@Override
public void afterCommit(Trx trx, boolean success) {
if (success)
pi.addLog(pi.getAD_PInstance_ID(), null, null, dropShipment.getDocumentInfo(), Table_ID, dropShipment.get_ID());
trx.removeTrxEventListener(this);
}
@Override
public void afterClose(Trx trx) {
}
});
}
}
if (dropShipment != null)
addDocsPostProcess(dropShipment);
// User Validation
@ -1956,7 +1982,14 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
dropShipment.setDropShip_Location_ID(0);
dropShipment.setDropShip_User_ID(0);
dropShipment.setMovementType(MOVEMENTTYPE_CustomerShipment);
if (!Util.isEmpty(getTrackingNo()) && getM_Shipper_ID() > 0 &&
DELIVERYVIARULE_Shipper.equals(getDeliveryViaRule()))
{
dropShipment.setTrackingNo(getTrackingNo());
dropShipment.setDeliveryViaRule(DELIVERYVIARULE_Shipper);
dropShipment.setM_Shipper_ID(getM_Shipper_ID());
}
// References (Should not be required
dropShipment.setSalesRep_ID(getSalesRep_ID());
dropShipment.saveEx(get_TrxName());

View File

@ -80,12 +80,14 @@ import org.compiere.util.Util;
* @version $Id: MWFActivity.java,v 1.4 2006/07/30 00:51:05 jjanke Exp $
*/
public class MWFActivity extends X_AD_WF_Activity implements Runnable
{
{
/**
*
*/
private static final long serialVersionUID = -3282235931100223816L;
private static final String CURRENT_WORKFLOW_PROCESS_INFO_ATTR = "Workflow.ProcessInfo";
/**
* Get Activities for table/record
* @param ctx context
@ -868,7 +870,6 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
m_newValue = null;
//m_trx = Trx.get(, true);
Trx trx = null;
boolean localTrx = false;
if (get_TrxName() == null)
@ -886,6 +887,8 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
//
try
{
if (m_process.getProcessInfo() != null)
Env.getCtx().put(CURRENT_WORKFLOW_PROCESS_INFO_ATTR, m_process.getProcessInfo());
if (!localTrx) {
// when cascade workflows, avoid setting a savepoint for each workflow
// use the same first savepoint from the transaction
@ -1007,10 +1010,22 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
{
trx.close();
}
Env.getCtx().remove(CURRENT_WORKFLOW_PROCESS_INFO_ATTR);
}
} // run
/**
* Get ProcessInfo instance of current workflow process
* @return {@link ProcessInfo}
*/
public static ProcessInfo getCurrentWorkflowProcessInfo()
{
Object o = Env.getCtx().get(CURRENT_WORKFLOW_PROCESS_INFO_ATTR);
if (o != null && o instanceof ProcessInfo)
return (ProcessInfo) o;
return null;
}
/**
* Perform Work.
* Set Text Msg.

View File

@ -715,6 +715,11 @@ public abstract class CreateFromShipment extends CreateFrom
inout.setDropShip_BPartner_ID(p_order.getDropShip_BPartner_ID());
inout.setDropShip_Location_ID(p_order.getDropShip_Location_ID());
inout.setDropShip_User_ID(p_order.getDropShip_User_ID());
if (MOrder.DELIVERYVIARULE_Shipper.equals(p_order.getDeliveryViaRule()) && p_order.getM_Shipper_ID() > 0)
{
inout.setDeliveryViaRule(p_order.getDeliveryViaRule());
inout.setM_Shipper_ID(p_order.getM_Shipper_ID());
}
}
}
if (m_invoice != null && m_invoice.getC_Invoice_ID() != 0)