生产用料清单保存校验仓库(Python添加校验器)

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

生产用料清单保存校验仓库(Python添加校验器)

## 背景 存在客户生产用料清单需要校验当发料方式为调拨领料或调拨倒冲时,仓库字段必须为生产车间的WIP仓,故通过次插件来实现 ## 实现 在保存操作上添加python插件 ```python import clr clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') from System import DateTime from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Metadata import * from Kingdee.BOS.Core.Metadata.EntityElement import * from Kingdee.BOS.Core.Validation import * from Kingdee.BOS.Log import Logger def OnAddValidators(e): validatePPBomStock=ValidatePPBomStock() validatePPBomStock.EntityKey="FBillHead" validatePPBomStock.AlwaysValidate=True e.Validators.Add(validatePPBomStock) class ValidatePPBomStock(AbstractValidator): def Validate(self,dataEntities,validateContext,ctx): for bill in dataEntities: workShopId=bill.DataEntity["WorkShopId_Id"] if(workShopId != 0): wipStockId=bill.DataEntity["WorkShopId"]["WIPStockId_Id"] entityDatas=bill.DataEntity['PPBomEntry'] for item in entityDatas: issueType=item['IssueType'] if(issueType == '3' or issueType=='4'): stockid=item['StockId_Id'] if(stockid != wipStockId): billId=str(bill["Id"]) seq=item['Seq'] errorInfo=ValidationErrorInfo(" ",billId,bill.DataEntityIndex,bill.RowIndex,billId,"第{0}行分录物料发料方式为调拨,仓库不等于生产车间WIP仓,请修改!".format(str(seq)),"",ErrorLevel.Error) validateContext.AddError(None,errorInfo) ``` ![Snipaste_20221108_134028.webp](/download/01006c0fb50143ba40719ac0656398b86e47.webp)

生产用料清单保存校验仓库(Python添加校验器)

## 背景存在客户生产用料清单需要校验当发料方式为调拨领料或调拨倒冲时,仓库字段必须为生产车间的WIP仓,故通过次插件来实现## 实现在...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息