To enable custom fields on the SO Invoices top-level form and Transactions grid after Invoice is released and/or closed, you should create an extension for SOInvoiceEntry and subscribe to the ARInvoice_RowSelected and ARTran_RowSelected events following the sample below:
public class SOInvoiceEntryExt : PXGraphExtension<SOInvoiceEntry>
{
private bool IsDisabled(ARInvoice doc)
{
return doc.Released == true
|| doc.Voided == true
|| doc.DocType == ARDocType.SmallCreditWO
|| doc.PendingPPD == true
|| doc.DocType == ARDocType.FinCharge
&& !Base.IsProcessingMode
&& Base.Document.Cache.GetStatus(doc) == PXEntryStatus.Inserted;
}
public void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARInvoice doc = e.Row as ARInvoice;
if (doc == null) return;
if (IsDisabled(doc))
{
PXUIFieldAttribute.SetEnabled<ARInvoiceExt.usrCustomTextField>(
sender, doc, true);
Base.Transactions.Cache.AllowUpdate = true;
}
}
public void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
var doc = Base.Document.Current;
ARTran row = e.Row as ARTran;
if (row != null && doc != null && IsDisabled(doc))
{
PXUIFieldAttribute.SetEnabled(sender, row, false);
PXUIFieldAttribute.SetEnabled<ARTranExt.usrCustomTextField>(
sender, row, true);
}
}
}
Additionally, you need to enable custom field added onto the top-level form in the Closed automation step:
This is how the SO Invoices screen should work after you apply the changes described above: