#二开案例# Python插件功能集合(持续更新)原创
金蝶云社区-henryleezs
henryleezs
80人赞赏了该文章 2,514次浏览 未经作者许可,禁止转载编辑于2024年09月27日 08:43:35

Python插件功能集合:


=======下推获取即时库存表单服务插件 begin===========NEW

import clr

clr.AddReference('Kingdee.BOS')

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

from Kingdee.BOS.Core import *

from Kingdee.BOS.Core.Metadata import *

from Kingdee.BOS.Core.Bill import *

from Kingdee.BOS.Core.DynamicForm import *

def AfterCreateModelData(e):  # 适用于单据下推自动获取场景


    if this.View.OpenParameter.Status == OperationStatus.ADDNEW and this.View.OpenParameter.CreateFrom == CreateFrom.Push:


this.View.EntryBarItemClick('FSaleOrderEntry','tbGetInvStockNew')    //备注:FSaleOrderEntry为明细页签标识,tbGetInvStockNew为明细行按钮获取即时库存标识。


=======下推获取即时库存表单服务插件 end===========


=======点击按钮执行触发执行SQL语句 begin===========NEW

import clr

clr.AddReference('Kingdee.BOS')

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

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

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


def BarItemClick(e):

    if e.BarItemKey=="tbButton_sql":

        DBUtils.Execute(this.Context,"UPDATE T_PUR_POORDER SET FCHANGEREASON='TEST002' WHERE FBILLNO = 'CGDD000019'")

        return



=======点击按钮执行触发执行SQL语句end============


=======单据保存、下推自动触发值更新begin===========NEW

import clr

clr.AddReference('System')

clr.AddReference('Kingdee.BOS')

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

from Kingdee.BOS.Core.DynamicForm.PlugIn import *

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

from System import *

def AfterCreateNewData(e):

        this.View.InvokeFieldUpdateService("FCONTACTUNIT"0);   //FCONTACTUNIT为需要触发值更新的字段名

=======单据保存、下推自动触发值更新end============


======python复制上一行begin======================NEW

import clr

clr.AddReference('Kingdee.BOS')

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

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

from Kingdee.BOS.Util import *

from Kingdee.BOS.Core.DynamicForm import *

from Kingdee.BOS.JSON import *

from System import *

from Kingdee.BOS.Core.Bill.PlugIn import *

def AfterCreateNewEntryRow(e):

   if(e.Entity.Key.Equals("FQUOTATIONENTRY") and e.Row >0):

       this.View.Model.SetValue("FTaxPrice", this.View.Model.GetValue("FTaxPrice", e.Row - 1), e.Row);    //复制第一行,   直接把e.row-1删掉,然后写0,0表示第一行

========python复制上一行end=====================

=========表单插件设置行高python插件begin============

import clr 

clr.AddReference('System') 

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

from Kingdee.BOS.Core.DynamicForm import * 

from Kingdee.BOS.JSON import * 

def AfterBindData(e):    

  this.View.GetControl("FEntity").SetRowHeight(80);

=======表单插件设置行高python插件end================

=======表单插件设置批改python插件begin===============

import clr

clr.AddReference('Kingdee.BOS') 

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


from Kingdee.BOS.Core import * 

from Kingdee.BOS.Core.Bill import * 

from Kingdee.BOS.Core.Bill.PlugIn import *


def BarItemClick(e): 

    if e.BarItemKey=="ora_tbBulkEdit": 

        if this.ListView.CurrentSelectedRowInfo==None: 

            this.View.ShowErrMessage("请选择数据行") 

            return 

        param = BillShowParameter() 

        param.FormId = FormIdConst.BD_BulkEdit 

        this.View.ShowForm(param)

========表单插件设置批改python插件end===============

========表单插件自动提交python插件begin==============

import clr

clr.AddReference('System')

clr.AddReference('System.Data')

clr.AddReference('Kingdee.BOS')

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

clr.AddReference('Kingdee.BOS.WebApi.FormService')

clr.AddReference('Kingdee.BOS.ServiceFacade.KDServiceFx')

clr.AddReference('Newtonsoft.Json')

from Kingdee.BOS import *

from Kingdee.BOS.Core.DynamicForm import *

from Kingdee.BOS.Core.DynamicService import *

from System import *

from System.Data import *

from System.Collections.Generic import *

from Kingdee.BOS.WebApi.FormService import *

from Kingdee.BOS.ServiceFacade.KDServiceFx import *

from Newtonsoft.Json.Linq import *


def EndOperationTransaction(e):

    for billObj in e.DataEntitys:

        billNo = str(billObj["BillNo"])

        apiResult = SubmitBill(billNo)


def SubmitBill(billNo):

    jsonData = """{"Numbers":["BILLNOS"]}"""

    json = jsonData.Replace("BILLNOS",billNo)

    apiResult = WebApiServiceCall.Submit(this.Context, "QM_InspectBill", json)

    return apiResult

========表单插件自动提交python插件end==============


========自定义插件设置分页信息文字的属性python插件begin=====

import clr; clr.AddReference('System'); clr.AddReference('Kingdee.BOS.Core'); from Kingdee.BOS.Core.DynamicForm import *; from Kingdee.BOS.JSON import *; def AfterBindData(e):     this.View.GetControl("FEntry").InvokeControlMethod("SetEditGridPageInfoText","测试选择行");

========自定义插件设置分页信息文字的属性python插件 end======


=======设置检验单检验项目子表体行背景色begin=============

clr.AddReference('mscorlib')

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

from System import *

from Kingdee.BOS.Core import*

from Kingdee.BOS.Core.Metadata import *

from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *

from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *


def EntityRowClick(e):

SetBackColor()


def DataChanged(e):

if e.Field.Key.upper() == "FInspectResult1".upper():

SetBackColor()


def SetBackColor():

entity = this.View.BusinessInfo.GetEntity("FItemDetail")

entrys = this.View.Model.GetEntityDataObject(entity)

grid = this.View.GetControl(entity.Key)

rowindex = 0

for entry in entrys:

if str(entry["INSPECTRESULT"]) =="1":

grid.SetRowBackcolor("#FFFF00",rowindex)

if str(entry["INSPECTRESULT"]) =="2":

grid.SetRowBackcolor("#00FFFF",rowindex)

rowindex = rowindex +1


=======设置检验单检验项目子表体行背景色end=============


=======单据保存、审核操作忽略可交互校验begin===========

import clr 

clr.AddReference('System') 

clr.AddReference('Kingdee.BOS') 

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


from System import * 

from Kingdee.BOS.Core.DynamicForm.PlugIn import * 


def OnAddValidators(e):   

  this.Option.SetVariableValue("IgnoreWarning", True)

=======单据保存、审核操作忽略可交互校验end===========



图标赞 80
80人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!