在SOLINE Acumatica上添加InventoryID选择器列

时间:2017-01-11 12:41:58

标签: acumatica

我需要在销售订单行上添加InventoryID选择器的客户部件号和供应商部件号列,以便用户在创建SO行时按部件号选择InventoryID。从Customization Project添加列>定制数据类>选择器列到选择器无法提供帮助。所以,我尝试自定义属性但仍然没有成功,因为SOLINE DAC上的InventoryID字段的定义是这样的:

[SOLineInventoryItem(Filterable=true)]
[PXDefault()]

需要帮助来确定如何自定义这种属性。

1 个答案:

答案 0 :(得分:2)

在Acumatica中,客户和供应商部件号存储在“库存项目”屏幕上的“交叉引用”选项卡中。如下面的屏幕截图所示,AlternateID在INItemXRef DAC中声明,并且InventoryItem和INItemXRef DAC之间存在一对多关系: enter image description here

话虽如此,不可能将Customer和Vendor Part Number列添加到InventoryID选择器中,因为这会导致重复的InventoryItem记录。

另一种解决方案是在InventoryItem DAC中创建自定义文本字段,然后覆盖InventoryItemMaint BLC扩展中的Persist以连接备用ID并将结果存储在自定义文本字段(DB列)中:

public class InventoryItemMaint_Extension : PXGraphExtension<InventoryItemMaint>
{
    [PXOverride]
    public void Persist(Action del)
    {
        using (PXTransactionScope ts = new PXTransactionScope())
        {
            InventoryItem item = Base.Item.Current;
            if (item != null && Base.itemxrefrecords.Cache.IsDirty)
            {
                string alternateIDs = string.Empty;
                foreach (INItemXRef crossRef in Base.itemxrefrecords.Select())
                {
                    alternateIDs = string.IsNullOrEmpty(alternateIDs) ?
                        crossRef.AlternateID : alternateIDs + "; " + crossRef.AlternateID;
                }
                item.GetExtension<InventoryItemExt>().UsrAlternateIDs = alternateIDs;
                Base.Item.Update(item);
            }

            del();
            ts.Complete();
        }
    }
}

为了简化初始设置,您还可以在InventoryItemMaint BLC扩展中实现RecalcAlternateIDs操作。 RecalcAlternateIDs操作将遍历应用程序中的所有Stock Items并连接Alternate ID:

public class InventoryItemMaint_Extension : PXGraphExtension<InventoryItemMaint>
{
    ...

    public PXAction<InventoryItem> RecalcAlternateIDs;
    [PXButton]
    [PXUIField(DisplayName = "Concatenate Alternate IDs")]
    protected void recalcAlternateIDs()
    {
        PXLongOperation.StartOperation(Base, () =>
        {
            InventoryItemMaint itemMaint = PXGraph.CreateInstance<InventoryItemMaint>();
            var items = PXSelect<InventoryItem, Where<InventoryItem.stkItem, Equal<boolTrue>>>.Select(itemMaint);
            foreach (InventoryItem item in items)
            {
                itemMaint.Clear();
                itemMaint.Item.Current = item;
                itemMaint.itemxrefrecords.Cache.IsDirty = true;
                itemMaint.Actions.PressSave();
            }
        });
    }
}

默认情况下,所有选择器控件都会针对键(或定义时为SubstituteKey)和描述(如果已定义)字段构建搜索索引。要扩展此列表,可以在Aspx中为PXSelector / PXSegmentMask控件将FilterByAllFields属性设置为True,或者按照以下步骤使用FastFilterFields。在我看来,FastFilterFields似乎是解决您的请求的更好选择。

将UsrAlternateIDs列添加到InventoryID选择器

中需要后续步骤
  1. 启动销售订单屏幕的布局编辑器(SO301000),然后从“操作”菜单中选择“编辑Aspx”选项:
  2. enter image description here

    1. 在Aspx文件中找到InventoryID选择器的声明:

      <px:PXSegmentMask CommitChanges=“True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" /> 
      
    2. 对于InventoryID选择器,通过声明UsrAlternateIDs列来追加列,然后单击Generate Customization Script:

      <px:PXSegmentMask CommitChanges="True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" >
          <GridProperties FastFilterFields="UsrAlternateIDs">
              <Columns>
                  <px:PXGridColumn DataField="UsrAlternateIDs" AutoGenerateOption="Add" Width="250px" />
              </Columns>
          </GridProperties>
      </px:PXSegmentMask>
      
相关问题