使用Python插件进行套打过滤(物料清单正查只打印外购件)原创
金蝶云社区-王文亮
王文亮
1人赞赏了该文章 623次浏览 未经作者许可,禁止转载编辑于2021年12月28日 16:43:30

示例需求:物料清单正查只打印外购件

需求背景:物料清单正查是个动态表单,动态表单的取数是插件定义的,故套打数据表格里面设置的过滤条件是无效的。

示例插件:

image.png

from System import *

def OnPrepareNotePrintData(e):
    if e.NotePrintTplId is None or e.NotePrintTplId.Equals("d1cc2bc2-5935-4c34-87f6-07548dabd0a5"):
        if e.DataSourceId.Equals("FBottomEntity",StringComparison.OrdinalIgnoreCase):
            tempList = filter(lambda x:(x["FErpClsID"] == '外购') , e.DataObjects);
            tempArray = Array.CreateInstance(e.DataObjects[0].GetType(), len(tempList));
            for index in range(len(tempArray)):
                tempArray[index] = tempList[index];
            e.DataObjects = tempArray;

image.png

注意:因为要使用“物料属性”字段进行过滤,所以套打模板上面必须绑定该字段,如果不想显示该字段的话,可以在数据表格下面插入一个普通行,随便一个单元格绑定该字段,然后在行属性里面设置该行不打印即可。

if e.NotePrintTplId is None or e.NotePrintTplId.Equals("d1cc2bc2-5935-4c34-87f6-07548dabd0a5")这句话是判断固定的套打模板才生效,使用时候要换成实际的套打模板唯一标识。

赞 1