采购订单货源关系检查
# 采购订单货源关系检查。
## 背景:
采购启用货源关系以后,采购申请单批量下推采购订单多时候,选不到供应商的时候也不知道如何判断是哪个物料没有维护货源关系
## 原理:
使用PY插件,点击按钮选择供应商,查询该供应商是否有跟这个单据上的物料绑定货源关系,如果没有,则弹出未绑定货源关系的物料
## 效果:
![image.webp](/download/010030be8f7eccc849049258a1a46b56c35c.webp)
## 代码:
# 引入clr运行库
# -*- coding: utf-8 -*-
import clr
# 添加对cloud插件开发的常用组件的引用
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.DataEntity')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference("Kingdee.BOS.Contracts")
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.App.Core')
clr.AddReference('Kingdee.BOS.ServiceHelper')
# 导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from Kingdee.BOS import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DependencyRules import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.Core.Const import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from Kingdee.BOS.Core.List import *
from Kingdee.BOS.Core.List.PlugIn import *
from Kingdee.BOS.Core.Metadata.EntityElement import *
from Kingdee.BOS.Core.Metadata.FieldElement import *
from Kingdee.BOS.Core.Permission import *
from Kingdee.BOS.JSON import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.ServiceHelper import *
from System import *
from System.Data import *
from System.Collections.Generic import *
# 子页面关闭回调处理方法
def ChildFromClosed(obj):
if obj.ReturnData:
rowids = obj.ReturnData.GetPrimaryKeyValues() # 选择的供应商id
sql = """SELECT Fname from T_BD_SUPPLIER_L WHERE FSUPPLIERID = '%s' """ % (rowids[0]).format("1")
sql_result = DBUtils.ExecuteDataSet(this.Context, sql)
tab = sql_result.Tables[0]
supplier_name = tab.Rows[0]['Fname']
billObj = this.View.Model.DataObject
order_date = billObj["Date"]
FBUSINESSTYPE = billObj["BUSINESSTYPE"]
entity = billObj["POOrderEntry"]
# material_ids = []
opResult = OperationResult()
index = 0
for line in entity:
matObj = line["MaterialId"]
MaterialId = matObj["Id"]
matNum = matObj["Number"]
# this.View.ShowMessage("MaterialId_type:%s" % (type(MaterialId)))
# material_ids.append({matNum: MaterialId})
sql = ("""SELECT
T_BD_MATERIAL.fnumber
FROM
T_PUR_CATALOG
LEFT JOIN T_PUR_CATALOGENTRY ON T_PUR_CATALOG.FID = T_PUR_CATALOGENTRY.fid
LEFT JOIN T_BD_MATERIAL ON T_PUR_CATALOGENTRY.FMaterialId = T_BD_MATERIAL.FMaterialId
WHERE
T_PUR_CATALOGENTRY.FMaterialId = %s
AND T_PUR_CATALOGENTRY.FETYSUPPLIERID = '%s'
AND T_PUR_CATALOG.FFORBIDSTATUS = 'A'
AND T_PUR_CATALOG.FISUSE = 0
AND T_PUR_CATALOGENTRY.FSUPPLYTYPE = '%s'
AND T_PUR_CATALOGENTRY.FEFFECTIVEDATE <= '%s'
AND T_PUR_CATALOGENTRY.FEXPIRYDATE >= '%s'""" % (
MaterialId, rowids[0], FBUSINESSTYPE, order_date, order_date)).format("1")
# this.View.ShowMessage("sql:%s" % (sql))
sql_result = DBUtils.ExecuteDataSet(this.Context, sql)
tab = sql_result.Tables[0]
if not tab.Rows:
# material_ids.append(matNum)
index += 1
err_message = "物料:%s 没有和供应商:%s 绑定货源关系" % (matNum, supplier_name)
operate = OperateResult(Name= matNum, Message=err_message, SuccessStatus=False)
opResult.OperateResult.Add(operate)
# this.View.ShowMessage("供应商id:%s;日期:%s ;物料:%s" % (rowids[0], order_date, str(material_ids)))
if index > 0:
# this.View.ShowErrMessage("物料:%s 没有和供应商:%s 绑定货源关系" % (material_ids, supplier_name))
this.View.ShowOperateResult(opResult.OperateResult)
else:
this.View.ShowMessage("供应商:%s 已经绑定全部货源关系" % (supplier_name))
# billno = dictionary["billno"]; # 从字典中取出具体字段
# 弹出动态表单子页面的方法
def ShowFilterForm():
showParam = ListShowParameter();
showParam.Context = this.Context
showParam.FormId = "BD_Supplier"
showParam.IsShowApproved = True
showParam.IsLookUp = True
showParam.MultiSelect = False
showParam.PermissionItemId = PermissionConst.View
showParam.OpenStyle.ShowType = ShowType.Modal
showParam.PageId = Guid.NewGuid().ToString()
showParam.ParentPageId = this.View.PageId
this.View.ShowForm(showParam, Action[FormResult](ChildFromClosed))
def BarItemClick(e):
key = e.BarItemKey.ToUpperInvariant()
if key == 'RKXG_TBBUTTON':
ShowFilterForm()
## 感谢周玉立老师的以及相关老师的支持
如果有更好的方法,欢迎指出
采购订单货源关系检查
# 采购订单货源关系检查。## 背景:采购启用货源关系以后,采购申请单批量下推采购订单多时候,选不到供应商的时候也不知道如何判断是哪...
点击下载文档
本文2024-09-16 17:30:10发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-16128.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章