单据体Python插件,值更新时触发查询并写值

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

单据体Python插件,值更新时触发查询并写值

场景:

实现单据体字段更新时,进行sql查询并回填当前行字段

import clr
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.ServiceHelper')
clr.AddReference('Newtonsoft.Json')

from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from System import *
from System.Data import *
from System.Net import *
from System.Text import *
from System.IO import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.App.Data import *
from System.Collections.Generic import List
from Kingdee.BOS.ServiceHelper import *

def DataChanged(e):
    
    if e.Field.Key == "FQty":
        cfmid=this.Model.GetValue("FMaterialId",e.Row)
        if cfmid is None:
            return
        fmid=str(cfmid["Id"])
        #this.View.Model.SetValue('FNote',fmid);
        #this.View.ShowMessage(str(fmid));
        if len(fmid)<=0:
            return
        sqlGetmu=("""select a.fbillno,b.F_xxa
                    from T_SAL_QUOTATION a with(nolock)
                    left join (select  FMATERIALID,FID,F_xxa from T_SAL_QUOTATIONENTRY with(nolock))b on b.fid=a.fid
                    where a.fdocumentstatus='C' 
                    and b.FMATERIALID='{0}'""").format(fmid);
        muinfo=DBUtils.ExecuteDynamicObject(this.Context,sqlGetmu);
        muno=muinfo[0][0]
        mu=muinfo[0][1]
        this.Model.SetValue("F_xxa",muno,e.Row)
        this.Model.SetValue("F_xxb",mu,e.Row)


单据体Python插件,值更新时触发查询并写值

场景:实现单据体字段更新时,进行sql查询并回填当前行字段import clrclr.AddReference('System')clr.AddReference('System.Data')clr.AddR...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息