Acumatica - 从代码调用流程发货操作

时间:2015-09-23 22:53:29

标签: acumatica

我正在开发Acumatica的扩展程序,我想做的其中一件事就是从代码执行“处理货件”屏幕上的“确认货件”和“准备发票”操作。我还需要发布发票。

为简化讨论,在代码中的某一点,我将在缓存中发货并指向SOShipmentEntry图表:

SOShipment soShipment = soShipmentGraph.Document.Search<SOShipment.shipmentNbr>(shipmentNbr);

在不同的点上,我希望能够确认发货,准备发票并发放发票。我已经做了很多挖掘,并且我找到了ConfirmShipment方法,但是我试图调用它时出错 - 装运计数器已损坏。我叫它:

SOOrder soOrder = PXSelect<SOOrder, Where<SOOrder.orderNbr,
    Equal<Required<SOOrder.orderNbr>>>>.Select(this, orderNbr);

soOrderGraph.Document.Current = soOrder;
soShipmentGraph.ConfirmShipment(soOrderGraph, soShipment);

Studio编译了它,但是在运行时我得到了损坏的计数器异常。在SOShipmentEntry中的PXAction逻辑中有一些我必须要的代码。我只是不知道如何直接从代码中调用操作。

感谢任何帮助。

2 个答案:

答案 0 :(得分:4)

直接调用函数是最明显的选择,但我们必须了解这些操作在图SOShipmentEntry中的工作原理。通过查看源代码,我们可以理解调用的PXAction如下:

public PXAction<SOShipment> action;
[PXUIField(DisplayName = "Actions", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton]
protected virtual IEnumerable Action(PXAdapter adapter,
    [PXInt]
    [PXIntList(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, new string[] { "Confirm Shipment", "Create Invoice", "Post Invoice to IN", "Apply Assignment Rules", "Correct Shipment", "Create Drop-Ship Invoice", "Print Labels", "Get Return Labels", "Cancel Return" })]
    int? actionID,
    [PXString()]
    string ActionName
)

通过进一步挖掘函数,我们可以注意到actionID=1执行的内容远不只是简单地调用public virtual void ConfirmShipment(SOOrderEntry docgraph, SOShipment shiporder)

case 1:
{
    List<object> _persisted = new List<object>();
    foreach (SOOrder item in Caches[typeof(SOOrder)].Updated)
    {
        _persisted.Add(item);
    }

    Save.Press();
    PXAutomation.CompleteAction(this);

    PXLongOperation.StartOperation(this, delegate()
    {
        SOShipmentEntry docgraph = PXGraph.CreateInstance<SOShipmentEntry>();
        SOOrderEntry orderentry = PXGraph.CreateInstance<SOOrderEntry>();

        orderentry.Caches[typeof(SiteStatus)] = docgraph.Caches[typeof(SiteStatus)];
        orderentry.Caches[typeof(LocationStatus)] = docgraph.Caches[typeof(LocationStatus)];
        orderentry.Caches[typeof(LotSerialStatus)] = docgraph.Caches[typeof(LotSerialStatus)];
        orderentry.Caches[typeof(ItemLotSerial)] = docgraph.Caches[typeof(ItemLotSerial)];

        PXCache cache = orderentry.Caches[typeof(SOShipLineSplit)];
        cache = orderentry.Caches[typeof(INTranSplit)];

        orderentry.Views.Caches.Remove(typeof(SiteStatus));
        orderentry.Views.Caches.Remove(typeof(LocationStatus));
        orderentry.Views.Caches.Remove(typeof(LotSerialStatus));
        orderentry.Views.Caches.Remove(typeof(ItemLotSerial));

        PXAutomation.StorePersisted(docgraph, typeof(SOOrder), _persisted);
        foreach (SOOrder item in _persisted)
        {
            PXTimeStampScope.PutPersisted(orderentry.Document.Cache, item, item.tstamp);
        }

        foreach (SOShipment shipment in list)
        {
            try
            {
                if (adapter.MassProcess) PXProcessing<SOShipment>.SetCurrentItem(shipment);
                if (shipment.Operation != SOOperation.Receipt)
                    docgraph.ShipPackages(shipment);
                docgraph.ConfirmShipment(orderentry, shipment);
            }
            catch (Exception ex)
            {
                if (!adapter.MassProcess)
                {
                    throw;
                }
                PXProcessing<SOShipment>.SetError(ex);
            }
        }
    });
}

我们可以理解,调用它的最佳方式是模拟单击按框架生成的按钮确认发货,并基本上使用参数PXAction<SOOrder> action调用actionID=1。要做到这一点,我们需要做一些体操。以下是我们向页面Confirm Shipment中的“货件”网格添加按钮Sales Order的示例:

namespace PX.Objects.SO
{
    public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {

        public PXAction<SOOrder> confirmShipment;

        [PXUIField(DisplayName = "Confirm Shipment")]
        [PXButton]
        protected virtual IEnumerable ConfirmShipment(PXAdapter adapter)
        {
            var soOrderShip = Base.shipmentlist.Current;
            if ( soOrderShip != null)
            {
                var graph = PXGraph.CreateInstance<SOShipmentEntry>();

                //We are recreating an adapter like the framework would do.
                var a = new PXAdapter(graph.Document)
                            {
                                Searches = new object[] { soOrderShip.ShipmentNbr }
                            };

                //Note: Confirm Shipment is Action 1 : 
                a.Arguments.Add("actionID", 1);
                PXLongOperation.StartOperation(Base, () => { foreach (SOShipment soShipment in graph.action.Press(a)); });

            }
            return adapter.Get();
        }

        protected virtual void SOOrderShipment_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected del)
        {
            var shipment = (SOOrderShipment)e.Row;
            if (shipment != null)
                confirmShipment.SetEnabled(!shipment.Confirmed.GetValueOrDefault());
            del(sender, e);
        }
    }
}

如果您想在此处测试整个项目的自定义项目XML

<Customization level="0" description="">
    <Page path="~/pages/so/so301000.aspx" pageSource="7T1rc9w2kt+3av8DT7dJ7VZFD7/ysp06aWTFqpWsWY3spO7qSkXNQBJjimRIjizt1d1vPzQeJN4AHzOSs9ZmE4lsohtAo9EvNF599R/RNL5C0VGcXS3xL683Jv++ER3HVY1KeHGQpPjZ/223T6rtg7y82Ud1nKRbN+TxRrS7rPM3tyirf0lKtCxeb9TlEm1EH+I0WcQ1OkW/L1FVv964jNMKP5/kC9by7OTZzpOdnZ2tuCrutubVxp//FOGfw+walUldvd4AlOccaiM6S2r47H1Wwy8LQvxG9NVPf/7Tn//0CneG0nl2X6DoQ1LWyzidxvV1QA+giVeYiB8neVbjjkSH+6835vj3J0AueTRN4zl6m6cLVMLL4np/thGVyyzGHZuh8hY38xMl/1Vx9+P01/24jmf5spwj0tiiaqArCo1JrJIL6M8ZGa5fkgXQinv6Fe4p7sO7+Aa/nP66dXLxG5rX1dbsBP9zUmIK3mR1eb8RTcvkJi7vPyTo0+uN/Xy+vMGEcjIIKZM4TS/i+cdJfnMTZ4tKeCeQOlPAIvhvUk+u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XI/SppW+6d5M/yjK1mqNqKPwrjaiHQxGFocVswgpsqGM31PBdUyd4LuUxuhZDAlYP1qSluAvKFA0zK4ZvK9WFOvu85h0Q92ISEP74o3o2/01DdB7p+Lmu712fObZtpB+ky3ft8wDNz28SLUg2Kd7y8eY999NjAOrh7cHtQatXfEE6nDaj1z+2mUxvbRPI0h/QJyLEdqc3LSjh0tERx6knx9W7bmvNProPZ13jVOmjUdPZQEHXEDR3Bxd+MGDXLR+Zy+zU6hY+vinSOOuJI0seC4+PkMqwtOo21Nd4y0hQVfvFAqtQ6LtIV42DuH3Myj+i8ReFNVTkPZ5dFjcUpVGzqlZ5CS7/T2MbiYwnW6r/dLMKv3SHwJZnUOZhmcyD33wyd6nCc4mkXn5OTjeGGsV9txVfzIxBX++/8B">
        <PXDataSource ID="ds" ParentId="phDS_ds" TypeFullName="PX.Web.UI.PXDataSource">
            <Children Key="CallbackCommands">
                <AddItem>
                    <PXDSCallbackCommand TypeFullName="PX.Web.UI.PXDSCallbackCommand">
                        <Prop Key="Name" Value="ConfirmShipment" />
                        <Prop Key="Visible" Value="false" />
                        <Prop Key="DependOnGrid" Value="grid5" />
                        <Prop Key="CommitChanges" Value="true" />
                    </PXDSCallbackCommand>
                </AddItem>
                <PXDSCallbackCommand Name="CalculateFreight" OriginalIndex="19" />
            </Children>
        </PXDataSource>
        <PXGrid ID="grid5" ParentId="phG_tab_Items#7_grid5" TypeFullName="PX.Web.UI.PXGrid">
            <Children Key="ActionBar.CustomItems">
                <AddItem>
                    <PXToolBarButton TypeFullName="PX.Web.UI.PXToolBarButton">
                        <Prop Key="Text" Value="Confirm Shipment" />
                        <Prop Key="Tooltip" Value="Confirm Shipment" />
                        <Prop Key="CommandSourceID" Value="ds" />
                        <Prop Key="CommandName" Value="ConfirmShipment" />
                    </PXToolBarButton>
                </AddItem>
            </Children>
        </PXGrid>
        <PXGridColumn DataField="ShipmentNbr" ParentId="phG_tab_Items#7_grid5_Levels#0_Columns#0" TypeFullName="PX.Web.UI.PXGridColumn">
            <Prop Key="CommitChanges" />
            <Prop Key="LinkCommand" />
        </PXGridColumn>
    </Page>
    <Graph ClassName="SOOrderEntry" Source="#CDATA" IsNew="True" FileType="ExistingGraph">
        <CDATA name="Source"><![CDATA[using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Avalara.AvaTax.Adapter;
using Avalara.AvaTax.Adapter.TaxService;
using PX.CCProcessingBase;
using PX.Common;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects.TX;
using AvaMessage = Avalara.AvaTax.Adapter.Message;
using POLine = PX.Objects.PO.POLine;
using POOrder = PX.Objects.PO.POOrder;
using System.Threading.Tasks;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects;
using PX.Objects.SO;

namespace PX.Objects.SO
{
    public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {

        public PXAction<SOOrder> confirmShipment;

        [PXUIField(DisplayName = "Confirm Shipment")]
        [PXButton]
        protected virtual IEnumerable ConfirmShipment(PXAdapter adapter)
        {
            var soOrderShip = Base.shipmentlist.Current;
            if ( soOrderShip != null)
            {
                var graph = PXGraph.CreateInstance<SOShipmentEntry>();

                //We are recreating an adapter like the framework would do.
                var a = new PXAdapter(graph.Document)
                            {
                                Searches = new object[] { soOrderShip.ShipmentNbr }
                            };

                //Note: Confirm Shipment is Action 1 : 
                a.Arguments.Add("actionID", 1);
                PXLongOperation.StartOperation(Base, () => { foreach (SOShipment soShipment in graph.action.Press(a)); });

            }
            return adapter.Get();
        }

        protected virtual void SOOrderShipment_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected del)
        {
            var shipment = (SOOrderShipment)e.Row;
            if (shipment != null)
                confirmShipment.SetEnabled(!shipment.Confirmed.GetValueOrDefault());
            del(sender, e);
        }
    }
}]]></CDATA>
    </Graph>
</Customization>

答案 1 :(得分:0)

我也通过这个装运柜台损坏了。

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

来自Hybridzz的答案对我有用,你可以查看一下。