保存时自动生成批号——python脚本

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

保存时自动生成批号——python脚本

原理参考:【[单据保存时如何自动生成批号](https://wenku.my7c.com/article/329936268761261824?productLineId=1)】 ### python实现(以采购订单为例) > 由于是直接在保存操作插件中调用的自动获取,支持导入时自动获取 ```python import clr clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') clr.AddReference('Kingdee.BOS.App') clr.AddReference('Kingdee.K3.SCM.Contracts') clr.AddReference('Kingdee.K3.Core') clr.AddReference('Kingdee.BOS.DataEntity') from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.Metadata.FieldElement import * from Kingdee.BOS.Core.Base import * from Kingdee.K3.SCM.Contracts import * from Kingdee.K3.Core.SCM.STK import * from Kingdee.BOS.Orm.DataEntity import * def OnPreparePropertys(e): e.FieldKeys.Add("FLot") def BeforeDoSaveExecute(e): lotField = this.BusinessInfo.GetField("FLot") if lotField == None or lotField.OrgFieldKey == "" or lotField.ControlFieldKey == "" or lotField.InputModel != lotField.Enum_InputModel.TextAndSelect: return exEntitySet = ExtendedDataEntitySet() exEntitySet.Parse(e.DataEntities, this.BusinessInfo) entitys = exEntitySet.FindByEntityKey(lotField.EntityKey) lotService = ServiceFactory.GetLotService(this.Context) codeRet = lotService.GenerateLotMasterByCodeRule(this.Context,this.BusinessInfo,lotField,entitys) lotLists = codeRet.CodeResults if lotLists == None or lotLists.Count == 0: return index = 0 for entity in entitys: lotPair = None for lotlist in lotLists: if lotlist.Key == index: lotPair = lotlist break if lotPair != None and lotPair.Value != None and lotPair.Value.Length > 0: lot = lotPair.Value[0] if lot != None: if lot["Id"] > 0: entity.DataEntity["FLot"] = lot entity.DataEntity["FLot_Text"] = lot["Number"] else: entity.DataEntity["FLot"] = None entity.DataEntity["FLot_Text"] = None index = index + 1 ``` **其他更多文章入口:**[https://wenku.my7c.com/link/s/lbRPP](https://wenku.my7c.com/link/s/lbRPP)

保存时自动生成批号——python脚本

原理参考:【[单据保存时如何自动生成批号](https://wenku.my7c.com/article/329936268761261824?productLineId=1)】### python实现(以采...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息