完成和操作后页面不会重新加载

时间:2015-08-13 03:13:39

标签: cloud erp acumatica

我在SO303000中定制了动作版本。这是我从SOInvoiceEntry复制的代码和我添加的代码:

    [PXUIField(DisplayName = "Release", Visible = false)]
    [PXButton()]
    public IEnumerable Release(PXAdapter adapter)
    {
        List<ARRegister> list = new List<ARRegister>();
        foreach (ARInvoice ardoc in adapter.Get<ARInvoice>())
        {
            if (Base.Document.Cache.GetStatus(ardoc) == PXEntryStatus.Notchanged) Base.Document.Cache.SetStatus(ardoc, PXEntryStatus.Updated);
            list.Add(ardoc);
        }

      //  skipAvalaraCallOnSave = true;
        Base.Save.Press();

        PXLongOperation.StartOperation(this, delegate()
        {
            PXTimeStampScope.SetRecordComesFirst(typeof(ARInvoice), true);

            List<ARRegister> listWithTax = new List<ARRegister>();
            foreach (ARInvoice ardoc in list)
            {
                if (ardoc.IsTaxValid != true && AvalaraMaint.IsExternalTax(Base, ardoc.TaxZoneID))
                {
                    ARInvoice doc = new ARInvoice();
                    doc.DocType = ardoc.DocType;
                    doc.RefNbr = ardoc.RefNbr;
                    doc.OrigModule = ardoc.OrigModule;
                    doc.ApplyPaymentWhenTaxAvailable = ardoc.ApplyPaymentWhenTaxAvailable;
                    listWithTax.Add(ARExternalTaxCalc.Process(doc));
                }
                else
                {
                    listWithTax.Add(ardoc);
                }
            }

            SOInvoiceEntry ie = PXGraph.CreateInstance<SOInvoiceEntry>();
            SOOrderShipmentProcess docgraph = PXGraph.CreateInstance<SOOrderShipmentProcess>();
            HashSet<object> processed = new HashSet<object>();

            ARDocumentRelease.ReleaseDoc(listWithTax, adapter.MassProcess, null, delegate(ARRegister ardoc, bool isAborted)
            {
                List<object> items = new List<object>();
                items.Add(ardoc);
                PXAutomation.RemovePersisted(ie, typeof(ARInvoice), items);

                docgraph.Clear();
                foreach (PXResult<SOOrderShipment, SOOrder> ordershipment in docgraph.Items.View.SelectMultiBound(new object[] { ardoc }))
                {
                    SOOrderShipment copy = PXCache<SOOrderShipment>.CreateCopy(ordershipment);
                    SOOrder order = ordershipment;
                    copy.InvoiceReleased = true;
                    docgraph.Items.Update(copy);

                    if (order.Completed == true && order.BilledCntr <= 1 && order.ShipmentCntr <= order.BilledCntr + order.ReleasedCntr)
                    {
                        foreach (SOAdjust adj in docgraph.Adjustments.Select(order.OrderType, order.OrderNbr))
                        {
                            SOAdjust adjcopy = PXCache<SOAdjust>.CreateCopy(adj);
                            adjcopy.CuryAdjdAmt = 0m;
                            adjcopy.CuryAdjgAmt = 0m;
                            adjcopy.AdjAmt = 0m;
                            docgraph.Adjustments.Update(adjcopy);
                        }
                    }
                    processed.Add(ardoc);
                }
                docgraph.Save.Press();
            });
            PXAutomation.StorePersisted(ie, typeof(ARInvoice), new List<object>(processed));
            foreach (ARInvoice ardoc in list)
            {
                PXDatabase.Execute("pp_DMS_SO_Invoice_InsertSettleDate",
             new PXSPInParameter("@CompanyID", PXContext.GetSlot<int?>("singleCompanyID")),
             new PXSPInParameter("@InvoiceType", ardoc.DocType),
             new PXSPInParameter("@InvoiceNBR", ardoc.RefNbr));
                createARDocument(ardoc);
            }

        });

        return list;
      }  
  }

当我发布文档时,我必须手动重新加载页面。我不知道为什么它不会自动重新加载。 我进行了调试,发现发生错误&#34;未处理的类型&#39; System.Reflection.TargetInvocationException&#39;发生在mscorlib.dll&#34;我认为它无法反映下一个操作的对象,因此它不会重新加载缓存。 感谢您的支持。

1 个答案:

答案 0 :(得分:0)

不确定您的确切问题,因为它需要进一步验证发生了什么。但是作为解决此问题的方法,如果您只想从代码重新加载屏幕,则可以抛出重定向所需的异常

完成所有操作后,创建发票条目实例,通过搜索确切文档设置当前,然后重定向到该图表。

例如代码:

PX.Objects.SO.SOInvoiceEntry invGraph = new PX.Objects.SO.SOInvoiceEntry();
invGraph.Document.Current = invGraph .Document.Search<PX.Objects.AR.ARInvoice>(<YOUR INVOICE NUMBER>);
throw new PXRedirectRequiredException(invGraph, "Reloading invoice");