您是正确的,日记帐交易页面不是由自动化步骤驱动的。
如果要在此屏幕的 GLTran(lines) 上启用自定义字段,则需要在 JournalEntry 图形扩展上覆盖 GLTran_RowSelected 和 Batch_RowSelected。此外,您可以重用 GetStateController 方法中使用的 IsBatchReadonly 函数。
在 Batch_RowSelected 事件处理程序上,您将:
-使用 GetStateController 方法中的 isBatchReadOnly 函数检查批处理是否为只读。
- 然后,在缓存中将 allowUpdate 设置为 true。
- 将所有 GLTran 字段设置为 readonly false
- 然后将 readonly 设置为所有 GLTran 字段,但您的自定义字段除外。
然后在 GLTran_RowSelected 事件处理程序上,您将设置启用您的自定义字段。
请参阅下面的示例:
public class JournalEntry_Extension : PXGraphExtension<JournalEntry>
{
protected void GLTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
{
GLTran row = (GLTran)e.Row;
if (del != null)
del(cache, e);
if (row != null)
{
PXUIFieldAttribute.SetEnabled<GLTranExt.usrCustomField1>(cache, row, true);
PXUIFieldAttribute.SetEnabled<GLTranExt.usrCustomField2>(cache, row, true);
}
}
protected void Batch_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
{
Batch row = (Batch)e.Row;
if (del != null)
del(cache, e);
if (row != null)
{
if (IsBatchReadonly(row))
{
//Set Cache Allow Update
cache.AllowUpdate = true;
Base.GLTranModuleBatNbr.Cache.AllowUpdate = true;
//First Set ReadOnly false to all fields
PXUIFieldAttribute.SetReadOnly(Base.GLTranModuleBatNbr.Cache, null, false);
//Then Set ReadOnly true to all fields but your custom ones
PXUIFieldAttribute.SetReadOnly<GLTran.accountID>(Base.GLTranModuleBatNbr.Cache, null, true);
PXUIFieldAttribute.SetReadOnly<GLTran.subID>(Base.GLTranModuleBatNbr.Cache, null, true);
.......
}
}
}
//Function used on the GetStateController method
private bool IsBatchReadonly(Batch batch)
{
return (batch.Module != GL.BatchModule.GL && Base.BatchModule.Cache.GetStatus(batch) == PXEntryStatus.Inserted)
|| batch.Voided == true || batch.Released == true;
}
}