![](/img/trans.png)
[英]Unable to Copy UDF from SOLine (SO301000) to SOShipLine(SO302000) on Create Shipment Action
[英]Unable to create a shipment all the SOLine Items to the Shipment Screen (SOShipLine-Manually we are bringing non-stock items to the shipment screen)
當我們創建裝運“ Is-Component”字段時,我們在選中此字段時在“銷售訂單”屏幕中新添加了此字段,並且當我們在“裝運”屏幕中處理裝運時,特定的庫存數據項不僅僅針對選中的“是組件”項目傳遞,未選中的“是組件”項目可以傳遞到裝運屏幕。
[PXOverride]
public IEnumerable Action(PXAdapter adapter, Nullable<Int32> actionID, Nullable<DateTime> shipDate, String siteCD, String operation, String ActionName, ActionDelegate baseMethod)
{
if (actionID == 1)
{
SOShipmentEntry ShipGraph = PXGraph.CreateInstance<SOShipmentEntry>();
PXGraph.InstanceCreated.AddHandler<SOShipmentEntry>((graph) =>
{
ShipGraph.RowInserting.AddHandler<SOShipLine>((sender, e) =>
{
foreach (SOLine line in Base.Transactions.Select())
{
ShipGraph.Transactions.Current = PXSelect<SOShipLine, Where<SOShipLine.shipmentNbr, Equal<Required<SOShipLine.shipmentNbr>>>>.Select(Base, line.InventoryID, line.OrderNbr);
SOShipLine ShipLine = new SOShipLine();
SOLineExt NonStklnExt = line.GetExtension<SOLineExt>();
if (ShipGraph.Transactions.Current == null)
{
//if (NonStklnExt.UsrIsComponent == true || NonStklnExt.UsrIsComponent == false || NonStklnExt.UsrInvFlag == true || NonStklnExt.UsrInvFlag == false || NonStklnExt.UsrStkInventoryID == null || NonStklnExt.UsrStkInventoryID != null)
//{
ShipLine.InventoryID = line.InventoryID;
ShipLine.TranDesc = line.TranDesc;
// }
ShipGraph.Transactions.Insert(ShipLine);
}
}
Base.Transactions.View.RequestRefresh();
});
});
}
return baseMethod(adapter, actionID, shipDate, siteCD, operation, ActionName);
}
我可以假設這些項目是基於標志添加的,而不總是基於該項目添加的。 如果是這種情況,我將檢查“非庫存”項目上的“需要裝運”標志以使其自動添加。
我將通過重寫SOShipmentEntry CreateShipment函數而不是SOShipLine插入處理程序來解決此問題。 確保覆蓋具有QuickProcessFlow的控件。
從那里,我將在創建貨件后像您一樣搜索初始訂單和訂單行。 您的邏輯是檢查標記是否已選中或未選中,並應進行更新。 例如,如果您想查找所有未檢查的組件中未根據NonStockShip標志自動添加的貨件,我將按照以下說明進行處理:
public delegate void CreateShipmentDelegate(SOOrder order, Nullable<Int32> SiteID, Nullable<DateTime> ShipDate, Nullable<Boolean> useOptimalShipDate, String operation, DocumentList<SOShipment> list, ActionFlow quickProcessFlow);
[PXOverride]
public void CreateShipment(SOOrder order, Nullable<Int32> SiteID, Nullable<DateTime> ShipDate, Nullable<Boolean> useOptimalShipDate, String operation, DocumentList<SOShipment> list, ActionFlow quickProcessFlow, CreateShipmentDelegate baseMethod)
{
baseMethod(order, SiteID, ShipDate, useOptimalShipDate, operation, list, quickProcessFlow);
if (order == null)
return; //do not process for shipments that did not have an order sent for some reason
//get all lines for non-stockitems that are not flagged to be shipped that have the component checked
var SalesOrderLines = PXSelectJoin<
SOLine,
InnerJoin<InventoryItem,
On<SOLine.inventoryID, Equal<InventoryItem.inventoryID>>>,
Where<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
And<SOLine.orderType, Equal<Required<SOLine.orderType>>,
And<InventoryItem.nonStockShip, Equal<False>,
And<InventoryItem.stkItem, Equal<False>,
And<SOLineExt.usrIsComponent, Equal<True>>>>>>>
.Select(Base, order.OrderNbr, order.OrderType);
foreach(SOLine SalesOrderLine in SalesOrderLines)
{
//double check that they were not added.... and match the orig line nbr
var ShipmentLinesForItem = PXSelect<
SOShipLine,
Where<SOShipLine.shipmentNbr, Equal<Current<SOShipment.shipmentNbr>>,
And<SOShipLine.shipmentType, Equal<Current<SOShipment.shipmentType>>,
And<SOShipLine.inventoryID, Equal<Required<SOShipLine.inventoryID>>,
And<SOShipLine.origLineNbr, Equal<Required<SOShipLine.origLineNbr>>>>>>>
.Select(Base, SalesOrderLine.InventoryID, SalesOrderLine.LineNbr);
if (ShipmentLinesForItem.Count == 0)
{
//create your shipment lines for these items
SOShipLine ShipmentLine = new SOShipLine();
//set fields required. See function SOOrderEntry.CreateShipmentFromSchedules for examples of fields that should be set.
Base.Transactions.Insert(ShipmentLine);
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.