Acumatica 2021 R2 Override Create Sales Order

Viewed 74

Acumatica seems to have moved the CreateSalesOrder method from OpportunityMaint to the new CRCreateSalesOrder class. I cannot figure out how to override the CreateSalesOrder method with the new structure. Below is the original code. Any help greatly appreciated.

using PX.Data;
using PX.Objects.AR;
using PX.Objects.CM;
using PX.Objects.Common.Discount;
using PX.Objects.CR;
using PX.Objects.CR.Extensions.CRCreateSalesOrder;
using PX.Objects.CS;
using PX.Objects.IN;
using PX.Objects.PO;
using PX.Objects.SO;
using PX.Objects.TX;
using System.Collections.Generic;
using static PX.Objects.CR.OpportunityMaint;

namespace CH.KV.CPLVendorSOPO
{
    public class CHKVOpportunityMaintExt : PXGraphExtension<OpportunityMaint>
    {
        public delegate void DoCreateSalesOrderDelegate(CreateSalesOrderFilter param);
        [PXOverride]
        public void DoCreateSalesOrder(CreateSalesOrderFilter param, DoCreateSalesOrderDelegate baseMethod)
        {
            DoCreateSalesOrderCHKVExt(param);
        }

        protected virtual void DoCreateSalesOrderCHKVExt(CreateSalesOrderFilter param)
        {
            bool recalcAny = param.RecalculatePrices == true ||
                             param.RecalculateDiscounts == true ||
                             param.OverrideManualDiscounts == true ||
                             param.OverrideManualDocGroupDiscounts == true ||
                             param.OverrideManualPrices == true;

            var opportunity = Base.Opportunity.Current;
            Customer customer = (Customer)PXSelect<Customer, Where<Customer.bAccountID, Equal<Current<CROpportunity.bAccountID>>>>.Select(Base);

            //do things

            docgraph.Save.Press();
        }
    }
}
1 Answers

You will need to find where the code was moved too. I have had to do something similar when acumatica shifted up some buttons within the Customer Payment Profile Maint Graph into its own dedicated class.

This is what the new graph extension declaration looked like I'm my case where the original was a direct extension of the Customer Payment Profile Maint Graph

public class APSPaymentProfileHostedFormExtension : PXGraphExtension<
    CustomerPaymentMethodMaint.PaymentProfileHostedForm, 
    CustomerPaymentMethodMaint>
{

For clues, you want to look for something like this that will be declared on the graph the button originally resided. In my case, it looked like this.

public class PaymentProfileHostedForm : Extensions.PaymentProfile.PaymentProfileGraph<CustomerPaymentMethodMaint, CustomerPaymentMethod>
    {

Hopefully, this is enough to get you in the right direction. Let me know how you make out?

Related