简单生产入库单推简单生产领料单实现一对一单据下推,并且支持携带上游入库单字段信息到下游案例(单据日期为例)原创
金蝶云社区-kaiming
kaiming
6人赞赏了该文章 268次浏览 未经作者许可,禁止转载编辑于2023年03月30日 16:24:58

简单生产入库到简单生产领料的单据转换代码中干预了分组的规则,所以在bos上配置不生效(注:简单生产入库到简单生产领料单的规则是BOM展开的那个,反而不是下面那个。)image.png如果要实现如下五张单推五张领料单的效果拷贝如下python插件注册即可

image.png

image.png

============分割=====================

import clr

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

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

clr.AddReference('System.Core')

from Kingdee.BOS.ServiceHelper import BusinessDataServiceHelper

from Kingdee.BOS.ServiceHelper import MetaDataServiceHelper

from System.Collections.Generic import Dictionary

from System.Collections.Generic import List

from System.Linq import Enumerable

from System import Object

from System import Int64

from Kingdee.BOS.Orm.DataEntity import DynamicObject


def OnAfterCreateLink(e):

spIds=List[Object]()

entityDatas = e.TargetExtendedDataEntities.FindByEntityKey('FEntity')

for entityData in entityDatas:

sBillId = entityData.DataEntity['SrcInterId']

if sBillId>0:

spIds.Add(sBillId)

if spIds.Count==0:

return

spMeta=MetaDataServiceHelper.Load(e.Context,'SP_InStock')

spBillDatas=BusinessDataServiceHelper.Load(e.Context,spIds.ToArray(),spMeta.BusinessInfo.GetDynamicObjectType())

if spBillDatas==None or spBillDatas.Length==0:

return

SPBills=Dictionary[Int64,DynamicObject]()

for spb in spBillDatas:

SPBills.Add(spb['Id'],spb)

targetBillHeads = e.TargetExtendedDataEntities.FindByEntityKey('FBillHead')

for targetBillHead in targetBillHeads:

srcInterid = targetBillHead.DataEntity['Entity'][0]['SrcInterId']

if SPBills.ContainsKey(srcInterid):

sBill=SPBills[srcInterid]

              targetBillHead.DataEntity['Date']=sBill['Date']


def OnBeforeGroupBy(e):

e.HeadGroupKey = 'FSrcInterId2'

================分割===================


OnBeforeGroupBy那段方法即可实现一对一单据下推,OnAfterCreateLink方法是将上游的单据日期携带到下游的赋值逻辑。


image.png

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

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

请选择打赏金币数 *

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