from clr import AddReference
AddReference('Kingdee.BOS.App')
from Kingdee.BOS.App.Data import DBUtils
def DataChanged(e):
if e.Key == 'FMaterialId':
row = e.Row
fnumber = this.Model.GetValue('FMaterialId').Number
org_num = this.Model.GetValue('FSaleOrgId').Number
sql = """
select FBASEQTY from T_STK_INVENTORY
where FMATERIALID=(select FMASTERID from T_BD_MATERIAL where FNUMBER='%s'
and FUSEORGID=(select FORGID from T_ORG_ORGANIZATIONS where FNUMBER='%s'))
and FSTOCKORGID=(select FORGID from T_ORG_ORGANIZATIONS where FNUMBER='%s')
""" % (fnumber, org_num, org_num)
return_data = DBUtils.ExecuteEnumerable(this.Context, sql)
for data in return_data:
this.Model.SetValue('F_TANG_STOCKQTY', data['FBASEQTY'], row)
推荐阅读