生产用料清单保存校验仓库(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仓,故通过次插件来实现## 实现在...
点击下载文档
本文2024-09-23 03:22:27发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-158444.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章