学习笔记-单据转换插件Python版
场景 :单据A的单据体根据物料汇总下推单据B的单据体,单据A的单据体不汇总下推单据B的子单据体
①新增单据转换规则,A单据体分组合并汇总下推单据B的单据体
②插件策略中,注册Python插件
import clr clr.AddReference("System") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.App") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference("Kingdee.BOS.App.Core") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference("Kingdee.BOS.Contracts") from System import * from System import StringComparison from Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args import * from Kingdee.BOS.App.Data import * from System.Collections.Generic import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.Metadata import SelectorItemInfo from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.Contracts import * from Kingdee.BOS.App.Core import * global sfilter def OnGetSourceData(e): fid=e.SourceData[0]["FId"]; global sfilter sfilter="FID="+str(fid) def AfterConvert(e): targetForm=e.TargetBusinessInfo.GetForm(); headEntity=e.Result.FindByEntityKey("FBillHead"); matIds=[] #sfilter="FID=100006" filter1=OQLFilter.CreateHeadEntityFilter(sfilter) viewService=ViewService() sourceBill=viewService.Load(this.Context,str(e.SourceBusinessInfo.GetForm().Id),None,filter1)[0]; extendedEntities=e.Result.FindByEntityKey("FEntity"); for dy1 in extendedEntities: matIds.append(dy1["MaterialID_Id"]); extEntity=headEntity[0]; billDoj=extEntity.DataEntity; toEntry1=billDoj["ProductEntity"] tgtSecondEntity=e.TargetBusinessInfo.GetEntity("FSubEntity"); sourceObjCollection=sourceBill["SAL_DELIVERYNOTICEENTRY"] for dym in sourceObjCollection:#循环处理 sindex=matIds.index(dym["MaterialID_Id"]) srcBillEntry1=extendedEntities[sindex]["STK_ASSEMBLYSUBITEM"] newRow=DynamicObject(tgtSecondEntity.DynamicObjectType); field=e.TargetBusinessInfo.GetField("FMaterialIDSETY") vendor=viewService.LoadSingle(this.Context,dym["MATERIALID_Id"], field.RefFormDynamicObjectType) #newRow["MaterialIDSETY"]=dym["MATERIALID"]; newRow["MaterialIDSETY"]=vendor; newRow["MaterialIDSETY_Id"]=dym["MATERIALID_Id"]; newRow["FUnitIDSETY"]=dym["UNITID"]; newRow["FBaseUnitIDSETY"]=dym["BaseUnitID"]; newRow["BaseQtySETY"]=dym["BASEUNITQTY"]; field1=e.TargetBusinessInfo.GetField("FStockStatusIDSETY") vendor1=viewService.LoadSingle(this.Context,dym["StockStatusId_Id"], field1.RefFormDynamicObjectType) newRow["FStockStatusIDSETY"]=vendor1; #newRow["FStockStatusIDSETY"]=dym["StockStatusId"]; newRow["FStockStatusIDSETY_Id"]=dym["StockStatusId_Id"]; newRow["DescriptionSETY"]=dym["NoteEntry"]; newRow["MTONOSETY"]=dym["MtoNo"]; newRow["OwnerTypeIDSETY"]=dym["OwnerTypeID"]; newRow["FOwnerIDSETY"]=dym["OwnerID"]; newRow["BomIDSETY"]=dym["BomID"]; newRow["FProduceDateSETY"]=dym["PRODUCEDATE"]; newRow["FEXPIRYDATESETY"]=dym["FEXPIRYDATE"]; newRow["AuxPropertyIDSETY"]=dym["AuxpropID"]; newRow["ExtAuxUnitQtySETY"]=dym["F_ora_JSQty"]; newRow["F_ora_KHHH"]=dym["F_ora_KHHH"]; newRow["LotSETY"]=dym["Lot"]; srcBillEntry1.Add(newRow);
注意:基础资料类型的字段,下游单据如果使用了引用属性,需要进行转换。
学习笔记-单据转换插件Python版
场景 :单据A的单据体根据物料汇总下推单据B的单据体,单据A的单据体不汇总下推单据B的子单据体①新增单据转换规则,A单据体分组合并汇总...
点击下载文档
本文2024-09-16 17:16:14发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14624.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章