如何使用“添加订单”弹出窗口以编程方式创建和确认订单的发货?

时间:2018-08-29 20:26:13

标签: acumatica

我正在尝试以编程方式创建和确认单个订单的发货。但是我仍然停留在如何选择“添加订单”弹出窗口上显示的所有行上以在“装运”屏幕上添加SOLines上。有什么帮助吗?

 string operation = SOOperation.Issue;
        SOShipmentEntry shipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>();

        BAccountR customer = null;
        INSite warehouse = null;
       PXResultset<SOOrder> objSOOrder = PXSelect<SOOrder, Where<SOOrder.customerRefNbr, Equal<Required<SOImportFilter.referenceID>>>>.Select(this, currentFilter.ReferenceID);
        foreach(SOOrder order in objSOOrder)
        {
            shipmentGraph.Clear();
            var shipment = shipmentGraph.Document.Insert();
            customer = (BAccountR)PXSelect<BAccountR,
            Where<BAccountR.bAccountID, Equal<Required<BAccountR.bAccountID>>>>
            .SelectSingleBound(shipmentGraph, new object[] { }, order.CustomerID);
            shipment.CustomerID = customer.BAccountID;
            shipment = shipmentGraph.Document.Update(shipment);
            warehouse = (INSite)PXSelect<INSite,
           Where<INSite.siteID, Equal<Required<INSite.siteID>>>>
           .SelectSingleBound(shipmentGraph, new object[] { }, "159");
            shipment.SiteID = warehouse.SiteID;
            shipment = shipmentGraph.Document.Update(shipment);
            var addorder = shipmentGraph.addsofilter.Insert();
            addorder.Operation = operation;
            addorder = shipmentGraph.addsofilter.Update(addorder);
            addorder.OrderType = order.OrderType;
            addorder = shipmentGraph.addsofilter.Update(addorder);
            addorder.OrderNbr = order.OrderNbr;
            addorder = shipmentGraph.addsofilter.Update(addorder);

            foreach (PXResult<SOShipmentPlan, SOLineSplit, SOLine> plan in 
                 shipmentGraph.soshipmentplan.Select())
            {
                SOShipmentPlan shipmentPlan = (SOShipmentPlan)plan;
                shipmentPlan.Selected = true;
                shipmentGraph.soshipmentplan.Update(plan);
                shipmentGraph.Actions.PressSave();

            }      

            shipmentGraph.Actions.PressSave();
        }   

1 个答案:

答案 0 :(得分:1)

我很难从描述中了解您要实现的功能。通常,您可以自动执行CreateShipment和ConfirmShipment操作。

也许您必须处理一个特例,如果所有阻止的事情都是您从“添加订单”智能面板内的网格中选择数据: enter image description here

使用“检查元素”功能,通过单击网格确定要定位的DataView的名称: enter image description here

使用View Business Logic源查找DataView源代码: enter image description here

从该DataView的源代码中,我们看到它返回了3个DAC(SOShipmentPlan,SOLineSplit和SOLine):

PXSelectJoinOrderBy<SOShipmentPlan,
InnerJoin<SOLineSplit, On<SOLineSplit.planID, Equal<SOShipmentPlan.planID>>,
InnerJoin<SOLine, On<SOLine.orderType, Equal<SOLineSplit.orderType>, And<SOLine.orderNbr, Equal<SOLineSplit.orderNbr>, And<SOLine.lineNbr, Equal<SOLineSplit.lineNbr>>>>>>,
OrderBy<Asc<SOLine.sortOrder, Asc<SOLine.lineNbr, Asc<SOLineSplit.lineNbr>>>>> soshipmentplan;

有了这些信息,我们现在可以使用Select方法来迭代DataView:

foreach (PXResult<SOShipmentPlan, SOLineSplit, SOLine> plan in Base.soshipmentplan.Select())
{
    SOShipmentPlan shipmentPlan = (SOShipmentPlan)plan;
    SOLineSplit lineSplit = (SOLineSplit)plan;
    SOLine line = (SOLine)plan;
}

我使用Base成员引用SOShipmentEntry图以获取DataView。在SOShipmentEntry图扩展的上下文中时,应使用此方法:

Base.soshipmentplan.Select()

如果您直接引用SOShipmentEntry图,则可以直接使用它:

SOShipmentEntry shipmentEntry = PXGraph.CreateInstance<SOShipmentEntry>();
shipmentEntry.soshipmentplan.Select()

编辑

用于自动执行“添加订单”对话框的代码:

shipmentEntry.addsofilter.Current.OrderType = SOOrderTypeConstants.SalesOrder;
shipmentEntry.addsofilter.Current.OrderNbr = "000001";
shipmentEntry.addsofilter.Update(shipmentEntry.addsofilter.Current);

foreach (SOShipmentPlan line in shipmentEntry.soshipmentplan.Select())
{
    line.Selected = true;
    shipmentEntry.soshipmentplan.Update(line);
}

shipmentEntry.addSO.Press();