copy

copy(self, filters=True, details=True, handlers=True)

使用范围: server

编程语言: python

父类: Item 类

描述说明

使用 copy 方法以创建实体项的一个副本(复制品)。 创建的副本不会被添加到 task 树 中,而且不再需要后,会被 Python 的垃圾回收器销毁。

副本对象的所有属性都按照创建任务树时的状态定义。 请见 工作流程

该方法可以有下列参数:

  • handlers - 如果这个参数的值是 true ,该实体项在服务端模块中的所有函数和事件处理程序在副本中依然可用。默认值是 true

  • filters - 如果这个参数的值是 true ,那么将为副本创建过滤器。

否则,副本没有过滤器。 默认值是 true

  • details - 如果这个参数的值是 true ,那么将为副本创建明细项。

否则,副本没有明细项。 默认值是 true

示例

def on_generate(report):
    cust = report.task.customers.copy()
    cust.open()

    report.print_band('title')

    for c in cust:
        firstname = c.firstname.display_text
        lastname = c.lastname.display_text
        company = c.company.display_text
        country = c.country.display_text
        address = c.address.display_text
        phone = c.phone.display_text
        email = c.email.display_text
        report.print_band('detail', locals())

另请参见

Task 树

工作流