当用户点击版本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。货件继续创建不再确认的正常货件。
答案 0 :(得分: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;
}
}