在 Acumatica 中禁用或隐藏标准按钮

Disable or Hide standard button in Acumatica

请告诉我如何隐藏 ADD LC 按钮,因为它在 acumatica 代码中定义为按条件显示。

这是显示此按钮的标准 acumatica 代码

#region Actions

        public PXAction<APInvoice> addLandedCost;
        public PXAction<APInvoice> addLandedCost2;

        [PXUIField(DisplayName = "Add LC", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = true)]
        [PXLookupButton]
        [APMigrationModeDependentActionRestriction(
            restrictInMigrationMode: true,
            restrictForRegularDocumentInMigrationMode: true,
            restrictForUnreleasedMigratedDocumentInNormalMode: true)]
        public virtual IEnumerable AddLandedCost(PXAdapter adapter)
        {
            if (Base.Document.Current != null &&
                Base.Document.Current.Released != true)
            {
                if (LandedCostDetailsAdd.AskExt((graph, view) =>
                {
                    landedCostFilter.Cache.ClearQueryCacheObsolete();
                    landedCostFilter.View.Clear();
                    landedCostFilter.Cache.Clear();

                    LandedCostDetailsAdd.Cache.ClearQueryCacheObsolete();
                    LandedCostDetailsAdd.View.Clear();
                    LandedCostDetailsAdd.Cache.Clear();
                }, true) == WebDialogResult.OK)
                {
                    return AddLandedCost2(adapter);
                }
            }

            return adapter.Get();
        }

        [PXUIField(DisplayName = "Add LC", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = true)]
        [PXLookupButton]
        [APMigrationModeDependentActionRestriction(
            restrictInMigrationMode: true,
            restrictForRegularDocumentInMigrationMode: true,
            restrictForUnreleasedMigratedDocumentInNormalMode: true)]
        public virtual IEnumerable AddLandedCost2(PXAdapter adapter)
        {
            if (Base.Document.Current != null &&
                Base.Document.Current.DocType.IsIn(APDocType.Invoice, APDocType.DebitAdj) &&
                Base.Document.Current.Released == false &&
                Base.Document.Current.Prebooked == false)
            {
                var landedCostDetails = LandedCostDetailsAdd.Cache.Updated.RowCast<POLandedCostDetailS>().Where(t => t.Selected == true).ToArray();
                Base.AddLandedCosts(landedCostDetails);
                landedCostDetails.ForEach(t => t.Selected = false);
            }
            return adapter.Get();
        }

        #endregion

        #region Events

        protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            APInvoice document = e.Row as APInvoice;
            if (document == null) return;

            var invoiceState = Base.GetDocumentState(cache, document);

            addLandedCost.SetVisible(invoiceState.IsDocumentInvoice || invoiceState.IsDocumentDebitAdjustment);

            PXUIFieldAttribute.SetEnabled(LandedCostDetailsAdd.Cache, null, false);

            bool allowAddLandedCost = invoiceState.IsDocumentEditable &&
                invoiceState.LandedCostEnabled &&
                !invoiceState.IsRetainageDebAdj;

            addLandedCost.SetEnabled(allowAddLandedCost);
            PXUIFieldAttribute.SetEnabled<POLandedCostDetailS.selected>(LandedCostDetailsAdd.Cache, null, allowAddLandedCost);
        }

这一行表示在什么条件下显示。如何在 APInvoice_RowSelected 中的扩展 class 中覆盖此条件?例如仅在 (invoiceState.IsDocumentInvoice)

时显示
addLandedCost.SetVisible(invoiceState.IsDocumentInvoice || invoiceState.IsDocumentDebitAdjustment);

阿尔乔姆,

我会写一个事件覆盖

protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
{
      baseHandler.Invoke(cache, e);

      // Now put your custom .SetEnabled function here and it will run after the base handler runs
}