本文介绍了通过交叉引用过滤库存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过交叉引用以及其他属性来自定义库存过滤。

I want to customize the filtering of inventory by cross reference along with other properties.

我为这样的库存项目添加了另外两个交叉引用项目。

I have added two other cross reference items for a stock item like this.

现在我要自定义库存过滤器

And now I want to customize, inventory filter in any other forms by the Alternate Type's Alternate Id value.

谢谢!

推荐答案

没有简单的方法就可以对Stock Item的备用ID添加搜索功能,而无需进行自定义。另外,请记住,我们在这里谈论的是库存物料和备用ID之间的一对多关系,这使得不可能简单地将备用ID列放到库存ID选择器中,因为这将导致同一库存物料显示为多个

There is no simple way to add search capabilities over Stock Item's Alternate IDs without a customization. Also, keep in mind that we are talking here about the one-to-many relationship between Stock Item and Alternate IDs, which makes it impossible to simply drop Alternate ID column into the Inventory ID selector as this will result in same Stock Item shown multiple times because of a necessary join with the Cross-Reference DAC.

您需要做的第一件事就是为InventoryItem DAC创建数据库绑定字段( 确保您在InventoryItem数据库中创建UsrAlternateIDs列 )以连接一个库存项目的所有备用ID( 注意可见性设置为PXUIVisibility.SelectorVisible在PXUIField上-此需要在库存ID选择器中显示备用ID列 ):

The first thing you need to do is create a database-bound field for the InventoryItem DAC (make sure you create UsrAlternateIDs column in the InventoryItem database) table to concatenate all Alternate IDs of a Stock Item (notice Visibility set to PXUIVisibility.SelectorVisible on PXUIField - this is required to show Alternate IDs column inside the Inventory ID selector):

public class InventoryItemExt : PXCacheExtension<InventoryItem>
{
    public abstract class usrAlternateIDs : IBqlField { }
    [PXDBString(4000, IsUnicode = true)]
    [PXUIField(DisplayName = "Alternate IDs", Visibility = PXUIVisibility.SelectorVisible)]
    public string UsrAlternateIDs { get; set; }
}

下一步是覆盖InventoryItemMaint BLC扩展中的Persist方法以重新生成每次用户在交叉引用选项卡中进行更改时,都将串联备用ID:

Next step is to override the Persist method in the InventoryItemMaint BLC extension to regenerate concatenated Alternate IDs every time the user makes changes in the Cross-Reference tab :

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();
        }
    }
}

最后,您应该添加PXSelector FastFilterFields属性中的 UsrAlternateIDs

And finally, you should add UsrAlternateIDs in PXSelector FastFilterFields property:

完成这3个步骤后,最终结果应如下所示:

Once these 3 steps are completed, the final result should look as follows:

要连接所有当前操作中的现有库存项目替代ID,您可以在库存项目屏幕上实施自定义操作。您可以在那之后删除操作。

To concatenate all currently existing Stock Item Alternative IDs in one step, you can implement a custom action on the Stock Items screen. You can remove the action after that.

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();
            }
        });
    }
}

这篇关于通过交叉引用过滤库存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 04:16