How do I add the Inventory Availability Status to Custom Grid like SO301000

谁说我不能喝 提交于 2019-12-11 17:23:12

问题


We are adding a custom screen that utilizes Site ID and Inventory ID in the row of the defined grid on the page. We would like to add the Inventory Availability details as shown on SO301000 (Sales Order Entry graph).

A) How do I access the status area of the grid to place text. B) Is there a standard method that I can access for the text used on SO301000.


回答1:


The feature is called StatusField.

You define the status field on the grid ASPX control:

<px:PXGrid ID="grid" runat="server" DataSourceID="ds" StatusField="Availability">

It can be set with a FieldSelecting event:

public void SOLine_Availability_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)

Sales order screen lumps it with the allocation custom data view which makes it hard to re-use:

public LSSOLine lsselect;

In LSSOLine class you'll find the Availability_FieldSelecting method that computes the value:

public override void Availability_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
    var fetchMode = ((SOLine) e.Row)?.Completed == true
        ? AvailabilityFetchMode.None
        : AvailabilityFetchMode.ExcludeCurrent;
    IQtyAllocated availability = AvailabilityFetch(sender, (SOLine)e.Row, fetchMode | AvailabilityFetchMode.TryOptimize);

    if (availability != null)
    {
        PXResult<InventoryItem, INLotSerClass> item = ReadInventoryItem(sender, ((SOLine)e.Row).InventoryID);

        decimal unitRate = INUnitAttribute.ConvertFromBase<SOLine.inventoryID, SOLine.uOM>(sender, e.Row, 1m, INPrecision.NOROUND);
        availability.QtyOnHand = PXDBQuantityAttribute.Round((decimal)availability.QtyOnHand * unitRate);
        availability.QtyAvail = PXDBQuantityAttribute.Round((decimal)availability.QtyAvail * unitRate);
        availability.QtyNotAvail = PXDBQuantityAttribute.Round((decimal)availability.QtyNotAvail * unitRate);
        availability.QtyHardAvail = PXDBQuantityAttribute.Round((decimal)availability.QtyHardAvail * unitRate);

        if(IsAllocationEntryEnabled)
        {
            Decimal? allocated = PXDBQuantityAttribute.Round((decimal)(((SOLine)e.Row).LineQtyHardAvail ?? 0m) * unitRate); ;
            e.ReturnValue = PXMessages.LocalizeFormatNoPrefix(Messages.Availability_AllocatedInfo,
                    sender.GetValue<SOLine.uOM>(e.Row), FormatQty(availability.QtyOnHand), FormatQty(availability.QtyAvail), FormatQty(availability.QtyHardAvail), FormatQty(allocated));
        }
        else
            e.ReturnValue = PXMessages.LocalizeFormatNoPrefix(Messages.Availability_Info,
                    sender.GetValue<SOLine.uOM>(e.Row), FormatQty(availability.QtyOnHand), FormatQty(availability.QtyAvail), FormatQty(availability.QtyHardAvail));


        AvailabilityCheck(sender, (SOLine)e.Row, availability);
    }
    else
    {
        //handle missing UOM
        INUnitAttribute.ConvertFromBase<SOLine.inventoryID, SOLine.uOM>(sender, e.Row, 0m, INPrecision.QUANTITY);
        e.ReturnValue = string.Empty;
    }

    base.Availability_FieldSelecting(sender, e);
}

I would advise to skip using LSSOLine and just copy it's FieldSelecting method.

That approach is documented in more detail in this other answer: https://stackoverflow.com/a/45034612/7376238



来源:https://stackoverflow.com/questions/55249309/how-do-i-add-the-inventory-availability-status-to-custom-grid-like-so301000

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!