0

当我们创建发货“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);
    }
4

1 回答 1

0

我可以假设这些项目是基于标志添加的,并不总是基于项目添加。如果是这种情况,我会检查非库存商品上的要求装运标志以自动添加它。

我会通过覆盖 SOShipmentEntry CreateShipment 函数而不是 SOShipLine Insert 处理程序来解决这个问题。确保覆盖具有 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);
        }
    }
}
于 2019-08-09T13:25:18.387 回答