本示例是基于之前我的提问 https://vip.kingdee.com/questions/103177493703928320
其目的是在 采购管理下采购退料单,在反审核前检查该组织下的退料日期所属的业务期间是否已经关帐,若已经关帐,不允许反审核,会引起错误。
挂在 反审核 按钮下面, 正确代码如下
import clr
clr.AddReference("System")
clr.AddReference('System.Data')
clr.AddReference("System.Core")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference('Kingdee.BOS.App')
from System.Data import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.Core.Log import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.KDThread import *
from Kingdee.BOS.DataEntity import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Core.Metadata import SelectorItemInfo
from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter ##查询参数实体类
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.Core.Bill.PlugIn.Args import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
def OnPreparePropertys(e):
e.FieldKeys.Add("Date")
e.FieldKeys.Add("PURCHASEORGID")
#检查是否关帐
def BeginOperationTransaction(e):
if len(e.DataEntitys)>0:
for dataobj in e.DataEntitys:
sql ="select a.FID from T_AP_CLOSEPROFILE a where a.FCATEGORY='AP' and a.FORGID ="+str(dataobj["PurchaseOrgId_Id"])
read = DBUtils.ExecuteDynamicObject(this.Context,sql,None,None,CommandType.Text)
if (read != None and len(read)>0):
raise Exception("该采购组织在该单据的退料日期已经关帐了,禁止反审核")
推荐阅读