单据上面增加科目字段后实现组织隔离原创
金蝶云社区-肖同学丶
肖同学丶
17人赞赏了该文章 85次浏览 未经作者许可,禁止转载编辑于2024年09月30日 15:46:55

import clr

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

clr.AddReference('Kingdee.K3.BD.ServiceHelper')

clr.AddReference('System')

from  System import * 

from System.Collections.Generic import List 

from  Kingdee.K3.BD.ServiceHelper import *


def BeforeF7Select(e): 


#FBASE需要根据实际的情况进行修改(修改一)取科目字段名大写

if e.FieldKey.upper()=='F_PLYA_BASE_QTR': 

#组织默认取当前登录组织 

#1 

orgId = this.Context.CurrentOrganizationInfo.ID

acctTableId = 0 

#如果存在主业务组织,则获取主业务组织字段 

#2 

filed = this.View.BillBusinessInfo.MainOrgField 

if filed: 

mainOrg = this.View.Model.GetValue(filed.Key) 

if mainOrg: 

orgId=mainOrg["Id"] 

#如果存在账簿字段,获取账簿的组织和科目表属性,账簿字段需要添加科目表和核算组织的引用属性

#FAccountBookID可以根据实际情况进行修改(修改二) 取账簿字段标识

acctBook = this.View.Model.GetValue("FAccountBookId") 

if acctBook: 

#取得核算组织 

orgId=acctBook["AccountOrgID_Id"] 

#this.View.ShowMessage(str(orgId))

#取得科目表 

acctTableId = acctBook["AccountTable_Id"] 

#设置科目表,当然如果知道科目表的内码,不通过账簿解析,也可以直接设置 e.DynamicFormShowParameter.CustomParams["FACCTTBLID"] = str(acctTableId) 

#传递组织参数 

e.DynamicFormShowParameter.CustomParams["AcctOrgIds"] = str(orgId) 

lst = List[Int64]() 

lst.Add(orgId) 

strAcctTableId = AccountServiceHelper.GetAvailableAccountIDTable(this.Context, lst, acctTableId, "All") 

this.View.ShowMessage(str(strAcctTableId))

if strAcctTableId: 

e.ListFilterParameter.Filter = " EXISTS (SELECT 1 FROM ({}) T2 WHERE FACCTID=T2.FACCOUNTID) ".format(strAcctTableId) 

elif acctTableId>0: 

e.ListFilterParameter.Filter = "FACCTTBLID = '"+str(acctTableId)+"'";


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

您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!

请选择打赏金币数 *

10金币20金币30金币40金币50金币60金币
可用金币: 0