当我们创建货件“ 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);
}
答案 0 :(得分:0)
我可以假定这些项目是基于标志添加的,而不总是基于该项目添加的。如果是这种情况,我会检查“非库存”项目上的“需要装运”标志以使其自动添加。
我将通过重写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);
}
}
}