应收单按物料明细收款,明细自定义了字段,想带到下游的收款单;由于单据转换不能多单据体关联,此时需要将自定义字段先更新到收款计划,再配置单据转换
应收单审核操作添加以下服务插件:
import clr
clr.AddReference('mscorlib')
clr.AddReference('Kingdee.BOS.App.Core')
from Kingdee.BOS.App.Core import *
# 插件挂在提交或者审核里面,不能放保存
# 如果需要字段在单据界面即时显示,在对应的操作下添加刷新字段
def OnPreparePropertys(e):
# 添加用到的字段标识
e.FieldKeys.Add("FMATERIALID_S")
e.FieldKeys.Add("F_JCHQ_test3")
e.FieldKeys.Add("FMATERIALID")
e.FieldKeys.Add("F_JCHQ_test1")
e.FieldKeys.Add("FPayConditon")
def EndOperationTransaction(e):
for dataEntity in e.DataEntitys:
FPayConditon = dataEntity["PayConditon"] # 收款条件
if FPayConditon != None:
if FPayConditon["RECMETHOD"] == '3': # 按物料明细收款
AP_PAYABLEENTRY = dataEntity["AP_PAYABLEENTRY"] # 明细
AP_PAYABLEPLAN = dataEntity["AP_PAYABLEPLAN"] # 收款计划
for n in AP_PAYABLEENTRY: # 明细
FMATERIALID = str(n["MATERIALID"].Id)
F_JCHQ_test1 = ('{0}').format(n["F_JCHQ_test1"])
for p in AP_PAYABLEPLAN: # 物料相同则更新收款计划中的字段为明细中的字段
FMATERIALID_S = str(p["FMATERIALID_S"].Id)
if FMATERIALID_S == FMATERIALID:
p["F_JCHQ_test3"] = F_JCHQ_test1
BusinessDataWriter(this.Context).Save(e.DataEntitys)
推荐阅读