在自定义产品网格中,自定义字段的行在自定义网站的一行向下移动 .
Background :
我们有一个自定义,它在 Headers 中提供单位边距和% . PXFormula用于DAC,用于任何依赖于计算 .
Opportunity Products有4个附加领域:
上次成本= InventoryItem的最后成本
总成本=数量*最后成本
Margin = ExtAmt - ExtCost
手动成本,一个允许手动覆盖上次成本的复选框
机会有2个增加的领域:
保证金总额=保证金总和
保证金%=保证金总额/销售总额
Problem :
自定义机会存在问题,当从现有商机复制记录或导入Excel文件时,行会移动一行 .
现有记录
复制/粘贴或从Excel导入后
Code :
我目前的代码:
public PXSelect
Where
Equal>>> Cost;
protected void CROpportunityProducts_RowInserting(PXCache cache,
PXRowInsertingEventArgs e, PXRowInserting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (CROpportunityProducts)e.Row;
if (row == null) return;
var rowExt = cache.GetExtension(row);
if (rowExt == null) return;
var cost = Cost.SelectSingle();
if (cache.GetValue(row, "usrManCost") == null) return;
if (cost != null && (bool)cache.GetValue(row, "usrManCost") == false)
{
cache.SetValueExt(row, cost.LastCost);
}
}
可能是什么导致了这个?我认为RowInserting事件为第一行返回0,因为PXSelect <>语句返回0,因为在下一行之前,InventoryItem不在缓存中 .
我想出的一个可能的解决方案是使用RowInserted . 这解决了使用复制/粘贴时的问题 . 但是,它会导致从Excel导入错误计算总保证金 .