如何在机会产品网格页脚中显示产品可用性? [英] How to display product availability in Opportunity Products Grid footer?

查看:78
本文介绍了如何在机会产品网格页脚中显示产品可用性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在销售订单文档网格页脚中。它显示产品的可用性。



解决方案

如果与销售订单进行比较,则在期间,销售订单行从LSSOLine获取其值Availabilty_FieldSelecting 。页面上的连线通过 StatusField = Availability 在选项卡上。我们可以通过添加未绑定扩展字段,然后在字段中选择填充值来执行类似操作。一种替代方法是实现一个 LSCROpportunityProducts 类,该类继承 LSSelect 类似于 LSSoLine (一个更好的首选解决方案)。为了保持这种简单性并集中精力让字段显示文本,我将使用扩展字段和在扩展图中选择一个简单字段作为机会。



(1)在dac扩展中,创建一个未绑定字段(MyAvailability是示例字段):

  [ PXTable(typeof(CROpportunityProducts.cROpportunityID),typeof(CROpportunityProducts.cROpportunityID),IsOptional = true)] 
[可序列化]
公共类CROpportunityProductsMyExtension:PXCacheExtension< CROpportunityProduct
{
#region MyAvailability
公共抽象类myAvailability:PX.Data.IBqlField
{
}
受保护的字符串_MyAvailability;
[PXString(IsUnicode = true)]
[PXUIField(DisplayName =产品可用性,Enabled = false)]
公共虚拟字符串MyAvailability
{
get
{
返回此。_MyAvailability;
}
set
{
this._MyAvailability = value;
}
}
#endregion
}

(2)在机会产品选项卡上,通过设置属性 StatusField 将新字段连接为网格状态值。需要修改页面以添加此值,并且添加时,页面应类似于以下内容(需要在项目中进行屏幕自定义->操作编辑ASPX并找到ProductsGrid以粘贴到StatusField和值中)

 < px:PXGrid ID = ProductsGrid SkinID = Details runat = server Width = 100% 
Height = 500px DataSourceID = ds ActionsPosition = Top BorderWidth = 0px
SyncPosition = true StatusField = MyAvailability>

(3)现在在图形扩展中填充字段:



编辑:使用 Current<> 并不总是包含正确的当前高亮显示用户界面中的行。根据 PXFieldSelectingEventArgs.Row 切换到 Required<> ,并且产品选项卡中的多行结果正确

 公共类CROpportunityMaintMyExtension:PXGraphExtension< OpportunityMaint>。 
{
public virtual void CROpportunityProducts_MyAvailability_FieldSelecting(PXCache sender,PXFieldSelectingEventArgs e)
{
var row =(CROpportunityProducts)e.Row;
if(row == null)
{
e.ReturnValue = string.Empty;
的回报;
}

INLocationStatus locationStatus = PXSelectGroupBy< INLocationStatus,
其中< INLocationStatus.inventoryID,等于< Required< CROpportunityProducts.inventoryID>>
And2< Where" .subItemID,等于< Required< CROpportunityProducts.subItemID>>,
或< Not< FeatureInstalled< PX.Objects.CS.FeaturesSet.subItem>>>,
和< Where< INLocation .siteID,等于< Required" CROpportunityProducts.siteID>>,
或< Required< CROpportunityProducts.siteID>,IsNull>>>,
Aggregate< OnStatus&InStatus SUM< INLocationStatus.qtyAvail>>>
> .Select(sender.Graph,row.InventoryID,row.SubItemID,row.SiteID,row.SiteID);

//是否需要转换为事务UOM ...(始终为基本单位)

十进制? qtyOnHand = locationStatus?.QtyOnHand;
十进制? qtyAvail = locationStatus?.QtyAvail;

e.ReturnValue = $现有数量= {qtyOnHand.GetValueOrDefault()};可用数量= {qtyAvail.GetValueOrDefault()};
}
}

结果:




In Sales Order documents grid footer. It displays the product's availability.

How to do the same in Opportunity products grid ? More so, how do you enforce it to be displayed at the footer instead of a simple grid column ? Is there such attribute ?

Thanks for the replies.

解决方案

If we compare to sales order, the sales order line gets its value from LSSOLine during Availabilty_FieldSelecting. The wire-up on the page is on the tab via StatusField="Availability". We can do something similar by adding an unbound extension field and then during a field selecting fill in the value. An alternative would be to implement an LSCROpportunityProducts class that is inherits LSSelect similar to LSSoLine (a better preferred solution). To keep this simple and focus on just getting the field to display text, I will use an extension field and a simple field selecting in the extension graph for opportunity.

(1) In a dac extension, create an unbound field (MyAvailability is the example field):

[PXTable(typeof(CROpportunityProducts.cROpportunityID), typeof(CROpportunityProducts.cROpportunityProductID), IsOptional = true)]
[Serializable]
public class CROpportunityProductsMyExtension : PXCacheExtension<CROpportunityProducts>
{
    #region MyAvailability
    public abstract class myAvailability : PX.Data.IBqlField
    {
    }
    protected string _MyAvailability;
    [PXString(IsUnicode = true)]
    [PXUIField(DisplayName = "Product Availability", Enabled = false)]
    public virtual string MyAvailability
    {
        get
        {
            return this._MyAvailability;
        }
        set
        {
            this._MyAvailability = value;
        }
    }
    #endregion
}

(2) On the opportunity products tab, wire up the new field as the grid status value by setting property StatusField. The page needs modified to add this value and should look something like this when added (requires screen customization in your project -> actions edit ASPX and locate ProductsGrid to paste in your StatusField and value):

<px:PXGrid ID="ProductsGrid" SkinID="Details" runat="server" Width="100%" 
Height="500px" DataSourceID="ds" ActionsPosition="Top" BorderWidth="0px" 
SyncPosition="true" StatusField="MyAvailability">

(3) Now in a graph extension populate the field:

Edit: The use of Current<> does not always contain the correct currently highlighted row in the UI. Switched to Required<> based on the PXFieldSelectingEventArgs.Row and the results are correct for multiple rows in the products tab.

public class CROpportunityMaintMyExtension : PXGraphExtension<OpportunityMaint>
{
    public virtual void CROpportunityProducts_MyAvailability_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
    {
        var row = (CROpportunityProducts) e.Row;
        if (row == null)
        {
            e.ReturnValue = string.Empty;
            return;
        }

        INLocationStatus locationStatus = PXSelectGroupBy<INLocationStatus,
            Where<INLocationStatus.inventoryID, Equal<Required<CROpportunityProducts.inventoryID>>,
                And2<Where<INLocationStatus.subItemID, Equal<Required<CROpportunityProducts.subItemID>>,
                        Or<Not<FeatureInstalled<PX.Objects.CS.FeaturesSet.subItem>>>>,
                    And<Where<INLocationStatus.siteID, Equal<Required<CROpportunityProducts.siteID>>,
                        Or<Required<CROpportunityProducts.siteID>, IsNull>>>>>,
            Aggregate<Sum<INLocationStatus.qtyOnHand, Sum<INLocationStatus.qtyAvail>>>
        >.Select(sender.Graph, row.InventoryID, row.SubItemID, row.SiteID, row.SiteID);

        // Need to convert to transaction UOM... (this is always base units)

        decimal? qtyOnHand = locationStatus?.QtyOnHand;
        decimal? qtyAvail = locationStatus?.QtyAvail;

        e.ReturnValue = $"Qty On hand = {qtyOnHand.GetValueOrDefault()} ; Qty Avail = {qtyAvail.GetValueOrDefault()}";
    }
}

The results:

这篇关于如何在机会产品网格页脚中显示产品可用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆