模仿销售订单录入客户信息后再录入物料编码就自动带出客户物料编码信息 客户物料编码 用于记录自己的学习
在调拨申请单增加客户字段,在明细增加 客户物料编码字段
增加python插件 代码如下:
import clr
clr.AddReference('System')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
from System import*
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.App.Data import *
def BeforeUpdateValue(e):
billObj = this.View.Model.DataObject;#单据头的数据包 1.先判断是否选择了客户
KHobj = billObj["F_TPRS_BASE_QTR"]
if KHobj is not None:# 2.如果选择了客户就取出客户编码
KHnumber = KHobj["Number"]
#F_TPRS_BASE_QTR
if e.Key == "FMATERIALID" : # 3.判断输入的列是否为物料列,如果是再进行下一步操作
hh=this.View.Model.GetEntryCurrentRowIndex("FEntity");#获取单据体当前焦点行号
if hh >= 0 : #4.如果行号大于等于0 获取 BeforeUpdateValue 方法的 value 因为是基础资料需要在解析一层获取number
aa = e.Value
cc = aa["Number"]
#bb = e.Key #FMATERIALID
#5.将客户编码和物料编码传入sql 获取对应的客户物料编码
sql = "select b.FCUSTMATNO from T_SAL_CUSTMATMAPPING a inner join T_SAL_CUSTMATMAPPINGENTRY b on a.fid = b.fid left join T_BD_CUSTOMER c on a.FCUSTOMERID = c.FCUSTID inner join T_BD_MATERIAL d on b.FMATERIALID = d.FMATERIALID where d.FNUMBER = '"+str(cc)+"' and c.fnumber = '" + str(KHnumber)+"'union all select FCUSTMATNO = ''"
KHnumbers = DBUtils.ExecuteScalar(this.Context,sql,None);
#this.Model.SetValue("FKHnumber",KHnumbers);
this.View.Model.SetItemValueByNumber("FKHnumber",KHnumbers,hh); #6.将sql返回的值 赋值到需求字段
#this.View.ShowMessage(KHnumbers+sql);#显示正常提示信息
如若报错 请检查代码缩进!!!!!!!!!
评论的缩进有问题在这继续发一下:
import clr
clr.AddReference('System')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
from System import*
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.App.Data import *
def DataChanged(e):
if e.Key == "FMATERIALID" or e.Key =="F_TPRS_Base1":
hh=this.View.Model.GetEntryCurrentRowIndex("FEntity");#获取单据体当前焦点行号
if hh >= 0 :
baseObj=this.Model.GetValue("FMaterialID",hh);
if baseObj is not None:
cc = baseObj["Number"]
khObj = this.Model.GetValue("F_TPRS_Base1",hh);
if khObj is not None:
KHnumber = khObj["Number"];
#this.View.ShowMessage(baseObj.ToString()+":"+cc.ToString()+","+khObj.ToString()+":"+KHnumber.ToString());#显示正常提示信息
sql = "select b.FCUSTMATNO from T_SAL_CUSTMATMAPPING a inner join T_SAL_CUSTMATMAPPINGENTRY b on a.fid = b.fid left join T_BD_CUSTOMER c on a.FCUSTOMERID = c.FCUSTID inner join T_BD_MATERIAL d on b.FMATERIALID = d.FMATERIALID where d.FNUMBER = '"+str(cc)+"' and c.fnumber = '" + str(KHnumber)+"'union all select FCUSTMATNO = ''"
KHnumbers = DBUtils.ExecuteScalar(this.Context,sql,None);
this.View.Model.SetItemValueByNumber("FKHnumber",KHnumbers,hh);
根据以上延申的需求:需要直接在明细实现需求,在明细直接输入物料和客户后 自动携带客户物料编码
import clr
clr.AddReference('System')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
from System import*
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.App.Data import *
def DataChanged(e):
if e.Key == "FMATERIALID" or e.Key =="F_TPRS_Base1":
hh=this.View.Model.GetEntryCurrentRowIndex("FEntity");#获取单据体当前焦点行号
if hh >= 0 :
baseObj=this.Model.GetValue("FMaterialID",hh);
if baseObj is not None:
cc = baseObj["Number"]
khObj = this.Model.GetValue("F_TPRS_Base1",hh);
if khObj is not None:
KHnumber = khObj["Number"];
#this.View.ShowMessage(baseObj.ToString()+":"+cc.ToString()+","+khObj.ToString()+":"+KHnumber.ToString());#显示正常提示信息
sql = "select b.FCUSTMATNO from T_SAL_CUSTMATMAPPING a inner join T_SAL_CUSTMATMAPPINGENTRY b on a.fid = b.fid left join T_BD_CUSTOMER c on a.FCUSTOMERID = c.FCUSTID inner join T_BD_MATERIAL d on b.FMATERIALID = d.FMATERIALID where d.FNUMBER = '"+str(cc)+"' and c.fnumber = '" + str(KHnumber)+"'union all select FCUSTMATNO = ''"
KHnumbers = DBUtils.ExecuteScalar(this.Context,sql,None);
this.View.Model.SetItemValueByNumber("FKHnumber",KHnumbers,hh);
模仿销售订单录入客户信息后再录入物料编码就自动带出客户物料编码信息 客户物料编码 用于记录自己的学习
本文2024-09-16 17:39:17发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-17099.html