【问题标题】:Confirming Shipment when Create Shipment called in Acumatica 2017 R2在 Acumatica 2017 R2 中调用 Create Shipment 时确认发货
【发布时间】:2018-04-03 04:42:12
【问题描述】:

当用户在版本 6.x 中单击“创建货件”时,我使用此问题的解决方案来确认货件。

Auto confirm shipment when create shipment from Sales Order by Automation Step

我已经升级到最新版本,但是当点击创建货件时,这个逻辑似乎不再起作用。相反,当调用while (PXLongOperation.GetStatus(Base.UID, out timespan, out ex) == PXLongRunStatus.InProcess) { } 行时,当在Watch 窗口中观察到段PXLongOperation.GetStatus(Base.UID, out timespan, out ex) 时,它返回DoesNotExist。货件继续创建不再确认的正常货件。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    这似乎对我有用(还包括执行 Update IN 操作):

        public delegate void CreateShipmentDelegate(SOOrder order, int? SiteID, DateTime? ShipDate, bool? useOptimalShipDate, string operation, DocumentList<SOShipment> list);
        [PXOverride]
        public virtual void CreateShipment(SOOrder order, int? SiteID, DateTime? ShipDate, bool? useOptimalShipDate, string operation, DocumentList<SOShipment> list, CreateShipmentDelegate baseMethod)
        {
            baseMethod(order, SiteID, ShipDate, useOptimalShipDate, operation, list);
            var shipment = Base.Document.Current;
    
            if (shipment.Hold == true)
            {
                shipment.Hold = false;
                //shipment Status must be set to null to apply 'New Open' Automation Step
                shipment.Status = null;
                shipment = Base.Document.Update(shipment);
                if (shipment.Hold == true || shipment.Status == SOShipmentStatus.Hold)
                {
                    throw new PXException("Shipment {0} cannot be taken off Hold", shipment.ShipmentNbr);
                }
            }
    
            shipment.ShipDate = shipment.ShipDate.Value.AddDays(1);
            Base.Document.Update(shipment);
            Base.Actions.PressSave();
    
    
            //Here you can add your custom logic
    
            //Call Confirm Shipment
            foreach (var shipmentAction in (Base.action.GetState(shipment) as PXButtonState).Menus)
            {
                if (shipmentAction.Command == "Confirm Shipment")
                {
                    PXAdapter shipmentAdapter = new PXAdapter(
                        new DummyView(Base, Base.Document.View.BqlSelect,
                            new List<object> { shipment }));
                    shipmentAdapter.Menu = shipmentAction.Command;
                    //to invoke Confirm Shipment action
                    Base.action.Press(shipmentAdapter).RowCast<SOShipment>().ToList();
                }
            }
    
            //Execute UpdateIN
            Base.UpdateIN.Press();
    
        }
        internal class DummyView : PXView
        {
            List<object> _Records;
            internal DummyView(PXGraph graph, BqlCommand command, List<object> records)
                : base(graph, true, command)
            {
                _Records = records;
            }
            public override List<object> Select(object[] currents, object[] parameters, object[] searches, string[] sortcolumns, bool[] descendings, PXFilterRow[] filters, ref int startRow, int maximumRows, ref int totalRows)
            {
                return _Records;
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      相关资源
      最近更新 更多