#使用技巧# 开发个Python在线测试功能

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

#使用技巧# 开发个Python在线测试功能

image.webp

一.在需要测试的单据上,添加对应字段

  ① 文本字段(Fpystr),用来写python语句

   ②按钮FEXECPY  用来点击执行

二.注册表单插件

import clr

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.App')

clr.AddReference('Kingdee.BOS.App.Core')

clr.AddReference('Kingdee.BOS.ServiceHelper')

clr.AddReference("Kingdee.BOS.ServiceFacade.Common")

#import sys

from Kingdee.BOS import *

from Kingdee.BOS.Core import *

from Kingdee.BOS.Core.DependencyRules 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.App.Data import *

from System.Collections.Generic import List

from Kingdee.BOS.ServiceHelper import *

from Kingdee.BOS.Core.DynamicForm import *

from Kingdee.BOS.Core.Metadata.EntityElement import *

from Kingdee.BOS.Core.Metadata.FieldElement import *

from Kingdee.BOS.Orm.DataEntity import *

from Kingdee.BOS.ServiceFacade import *

def ButtonClick(e):

kbutton=e.Key.ToUpperInvariant();

if(kbutton=="FEXECPY"):

try:

pystr=this.Model.GetValue("Fpystr").ToString()

exec(pystr.replace('\r',''))

except Exception as e:

this.View.ShowMessage("代码错误,"+str(e))

三.编写常用Python测试验证
this.View.ShowMessage("测试提示框")

this.Model.setValue("FBillNo","测试控件赋值")

获取单据信息JSON

this.View.ShowMessage(DynamicObjectToJson(this.Model.DataObject))

获取明细信息JSON

this.View.ShowMessage(DynamicObjectToJson(this.Model.DataObject["POOrderEntry"]))

image.webp

获取第一行金额

this.View.ShowMessage(DynamicObjectToJson(this.Model.DataObject["POOrderEntry"][0]["Amount"]))

image.webp

获取明细金额汇总

amt=0

for r in this.Model.DataObject["POOrderEntry"]:

    amt=amt+r["Amount"]

this.View.ShowMessage(str(amt))


类似于表达式测试功能,仅用于测试。

this.View.ShowMessage(DynamicObjectToJson(this.Model.DataObject["POOrderEntry"]))

#使用技巧# 开发个Python在线测试功能

一.在需要测试的单据上,添加对应字段 ① 文本字段(Fpystr),用来写python语句 ②按钮FEXECPY 用来点击执行二.注册表单插件import ...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息