一些用户字段已添加到 ARInvoice 输入屏幕 (AR301000)。用户字段存在于事务网格中。它们只是文本字段。没有关联的自定义逻辑,并且绑定到数据库表。
用户希望在发票发布后修改特定的用户文本字段 - 实现此目的的最佳方法是什么?
一些用户字段已添加到 ARInvoice 输入屏幕 (AR301000)。用户字段存在于事务网格中。它们只是文本字段。没有关联的自定义逻辑,并且绑定到数据库表。
用户希望在发票发布后修改特定的用户文本字段 - 实现此目的的最佳方法是什么?
值得庆幸的是,ARInvoces 条目屏幕上的事务网格永远不会被自动化步骤禁用。Transactions 网格的所有 UI 表示逻辑仅在 ARInvoiceEntry BLC 中定义:
public class ARInvoiceEntry : ARDataEntryGraph<ARInvoiceEntry, ARInvoice>, PXImportAttribute.IPXPrepareItems
{
...
protected virtual void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
ARInvoice doc = e.Row as ARInvoice;
if (doc == null) return;
...
bool shouldDisable = doc.Released == true
|| doc.Voided == true
|| doc.DocType == ARDocType.SmallCreditWO
|| doc.PendingPPD == true
|| doc.DocType == ARDocType.FinCharge && !IsProcessingMode && cache.GetStatus(doc) == PXEntryStatus.Inserted;
if (shouldDisable)
{
...
Transactions.Cache.AllowDelete = false;
Transactions.Cache.AllowUpdate = false;
Transactions.Cache.AllowInsert = false;
...
}
else
{
...
Transactions.Cache.AllowDelete = true;
Transactions.Cache.AllowUpdate = true;
Transactions.Cache.AllowInsert =
doc.CustomerID != null &&
doc.CustomerLocationID != null &&
doc.DocType != ARDocType.FinCharge &&
(doc.ProjectID != null || !PM.ProjectAttribute.IsPMVisible(this, BatchModule.AR));
...
}
...
}
protected virtual void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARTran row = e.Row as ARTran;
if (row != null)
{
PXUIFieldAttribute.SetEnabled<ARTran.defScheduleID>(sender, row, row.TranType == ARInvoiceType.CreditMemo || row.TranType == ARInvoiceType.DebitMemo);
PXUIFieldAttribute.SetEnabled<ARTran.deferredCode>(sender, row, row.DefScheduleID == null);
}
}
...
}
要在 ARInvoice 发布后在 AR301000 上启用自定义字段,您应该完成以下相对简单的步骤:
将ARInvoice_RowSelected事件处理程序中的 ARTran 缓存的 AllowUpdate设置为true
调用静态PXUIFieldAttribute.SetEnabled方法以禁用所有 ARTran 字段,除了用户想要修改的特定自定义文本字段
完整的代码片段如下所示:
public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
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 cache, PXRowSelectedEventArgs e)
{
ARInvoice doc = e.Row as ARInvoice;
if (doc == null) return;
if (IsDisabled(doc))
{
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);
}
}
}