二开案例:采购入库单保存时校验上游采购订单的状态Python插件
采购入库单保存时校验上游采购订单的状态,可以在保存操作的服务插件中注册下面的python插件。
业务场景:
采购订单审核,正常下推收料后,由于业务调整,采购订单被关闭或行终止,此时通过收料通知单下推入库时,需要控制。
实现方案:
参考代码:
import clr clr.AddReference("mscorlib") clr.AddReference('System') clr.AddReference('System.Data') clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.App") clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference('Kingdee.BOS.Contracts') clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Newtonsoft.Json') from Kingdee.BOS import * from Kingdee.BOS.App.Data import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import * from Kingdee.BOS.Util import * from System import * from System.Collections.Generic import * from System.Data import * from Kingdee.BOS.Core import * from Kingdee.BOS.Contracts import * from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.DataEntity import * from Kingdee.BOS.Core.Log import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.DynamicForm import * from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import * from Kingdee.BOS.App.Data import * from System.Collections.Generic import List from Kingdee.BOS.ServiceHelper import * from Newtonsoft.Json import JsonConvert from Newtonsoft.Json.Linq import * from Kingdee.BOS.Core.Validation import * def OnAddValidators(e): validator = OneValidator() validator.EntityKey = "FBillHead" validator.AlwaysValidate = True e.Validators.Add(validator) class OneValidator(AbstractValidator): def Validate(self, dataEntities, validateContext,ctx): poentrys = List[long]() for bill in dataEntities: entrys = bill["InStockEntry"]#采购入库单明细 for entry in entrys: poentrys.Add(int(entry["POORDERENTRYID"]))#采购订单分录内码 if poentrys != None and len(poentrys) > 0: sql = """SELECT DISTINCT T1.FBILLNO FROM T_PUR_POORDER T1 INNER JOIN T_PUR_POORDERENTRY T2 ON T1.FID = T2.FID WHERE T2.FENTRYID IN ({0}) AND (T1.FDOCUMENTSTATUS <> 'C' OR T1.FCLOSESTATUS = 'B' OR T1.FCANCELSTATUS = 'B' OR T2.FMRPCLOSESTATUS = 'B' OR T2.FMRPTERMINATESTATUS = 'B')""".format(",".join(str(o) for o in poentrys)) dyc = DBUtils.ExecuteReader(this.Context, sql)#查询采购订单是否存在非审核或者已关闭或者已作废 while dyc.Read(): poBillNo = str(dyc["FBILLNO"]) msg = "当前采购入库单关联的上游采购订单【{0}】存在未审核或者已关闭或者已作废或者已终止的数据,不允许保存!".format(poBillNo) info = ValidationErrorInfo("","0", 0,0,"0", msg,"状态验证",ErrorLevel.Error) validateContext.AddError(None,info)#抛出异常 dyc.Close()
二开案例:采购入库单保存时校验上游采购订单的状态Python插件
采购入库单保存时校验上游采购订单的状态,可以在保存操作的服务插件中注册下面的python插件。业务场景:采购订单审核,正常下推收料后,由...
点击下载文档
本文2024-09-16 19:01:03发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-25866.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章