在操作列表审核,服务插件, 添加
import clr
clr.AddReference('System')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
from System import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Validation import *
from Kingdee.BOS.Log import Logger
def OnAddValidators(e):
validator = OneValidator()
validator.EntityKey = "FBillHead"
validator.AlwaysValidate = True
e.Validators.Add(validator)
class OneValidator(AbstractValidator):
def Validate(self, dataEntities, validateContext,ctx):
for bill in dataEntities:
custID = bill["F_UAGW_CustID"]
entrys = bill["SaleOrderEntry"]#销售订单明细实体
for entry in entrys:
seq = entry["Seq"]#序号
FNumber = entry["MaterialId"]["Number"]#物料编码
taxprice= entry["TaxPrice"]#含税单价
sysprice= entry["SysPrice"]#系统定价
#加入自定义条件
if (custID <>"HW28" and FNumber[0:3] <> 'F01' and FNumber[0:3] <> 'F02' and FNumber[0:3] <> 'F08' and FNumber[0:3] <> 'F10' and FNumber[0:1] <> 'A' and FNumber[0:2] <> 'FX') and (sysprice == 0 or taxprice <> sysprice) :
billId = str(bill["Id"])
msg = '''当前销售订单第{0}行没有价格或价格与价目表不符,请检查'''.format(seq)
info = ValidationErrorInfo("",billId, bill.DataEntityIndex,seq,billId, msg,"表体校验",ErrorLevel.Error)
validateContext.AddError(None,info)
推荐阅读