我正在尝试将一些用户字段从CRM报价复制到销售订单。 CRM报价使用与销售报价不同的对象,并且似乎没有将其重新关联的方法。我尝试覆盖“创建销售订单”以添加处理程序,但这似乎不起作用。任何帮助将不胜感激。这是我尝试的代码:
public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
public delegate IEnumerable CreateSalesOrderDelegate(PXAdapter adapter);
[PXOverride]
public virtual IEnumerable CreateSalesOrder(PXAdapter adapter, CreateSalesOrderDelegate baseMethod)
{
Base.RowInserting.AddHandler<SOLine>((sender, e) =>
{
SOLine orderLine = e.Row as SOLine;
if (orderLine == null) return;
SOLineExt orderLineExt = orderLine.GetExtension<SOLineExt>();
var product = Base.Products.Current;
CROpportunityProductsExt productExt = product.GetExtension<CROpportunityProductsExt>();
orderLineExt.UsrHasAnticipatedDiscount = productExt.UsrHasAnticipatedDiscount;
orderLineExt.UsrAnticipatedDiscountPct = productExt.UsrAnticipatedDiscountPct;
orderLineExt.UsrAnticipatedDiscountAmt = productExt.UsrAnticipatedDiscountAmt;
orderLineExt.UsrAnticipatedUnitPrice = productExt.UsrAnticipatedUnitPrice;
orderLineExt.UsrTotalAnticipatedDiscountAmt = productExt.UsrTotalAnticipatedDiscountAmt;
});
return baseMethod(adapter);
}
}
谢谢!
答案 0 :(得分:1)
有两个帖子回答了这个问题:
Populate custom field while creating sale order from opportunity
How to pass custom field vales from Opportunity to sales Order?
总而言之,您可以在按钮操作内添加rowinserting事件处理程序,或者我的首选项位于DoCreateSalesOrder(扩展OpportunityMaint)内,如下例所示。
ngOnInit() {
this.loadData()
}
loadData() {
this.router.navigate([this.route.queryParams.toArray()]);
}