当前位置: 首页>>代码示例>>Python>>正文


Python Transaction.values方法代码示例

本文整理汇总了Python中trytond.transaction.Transaction.values方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.values方法的具体用法?Python Transaction.values怎么用?Python Transaction.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trytond.transaction.Transaction的用法示例。


在下文中一共展示了Transaction.values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copy

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import values [as 别名]
    def copy(cls, locations, default=None):
        if default is None:
            default = {}

        default['left'] = 0
        default['right'] = 0

        res = []
        for location in locations:
            if location.type == 'warehouse':

                wh_default = default.copy()
                wh_default['type'] = 'view'
                wh_default['input_location'] = None
                wh_default['output_location'] = None
                wh_default['storage_location'] = None
                wh_default['childs'] = None

                new_location, = super(Location, cls).copy([location],
                    default=wh_default)

                with Transaction().set_context(
                        cp_warehouse_locations={
                            'input_location': location.input_location.id,
                            'output_location': location.output_location.id,
                            'storage_location': location.storage_location.id,
                            },
                        cp_warehouse_id=new_location.id):
                    cls.copy(location.childs,
                        default={'parent': new_location.id})
                cls.write([new_location], {
                        'type': 'warehouse',
                        })
            else:
                new_location, = super(Location, cls).copy([location],
                    default=default)
                warehouse_locations = Transaction().context.get(
                    'cp_warehouse_locations') or {}
                if location.id in warehouse_locations.values():
                    cp_warehouse = cls(
                        Transaction().context['cp_warehouse_id'])
                    for field, loc_id in warehouse_locations.iteritems():
                        if loc_id == location.id:
                            cls.write([cp_warehouse], {
                                    field: new_location.id,
                                    })

            res.append(new_location)
        return res
开发者ID:aleibrecht,项目名称:tryton-modules-ar,代码行数:51,代码来源:location.py

示例2: copy

# 需要导入模块: from trytond.transaction import Transaction [as 别名]
# 或者: from trytond.transaction.Transaction import values [as 别名]
    def copy(cls, locations, default=None):
        if default is None:
            default = {}

        default["left"] = 0
        default["right"] = 0

        res = []
        for location in locations:
            if location.type == "warehouse":

                wh_default = default.copy()
                wh_default["type"] = "view"
                wh_default["input_location"] = None
                wh_default["output_location"] = None
                wh_default["storage_location"] = None
                wh_default["childs"] = None

                new_location, = super(Location, cls).copy([location], default=wh_default)

                with Transaction().set_context(
                    cp_warehouse_locations={
                        "input_location": location.input_location.id,
                        "output_location": location.output_location.id,
                        "storage_location": location.storage_location.id,
                    },
                    cp_warehouse_id=new_location.id,
                ):
                    cls.copy(location.childs, default={"parent": new_location.id})
                cls.write([new_location], {"type": "warehouse"})
            else:
                new_location, = super(Location, cls).copy([location], default=default)
                warehouse_locations = Transaction().context.get("cp_warehouse_locations") or {}
                if location.id in warehouse_locations.values():
                    cp_warehouse = cls(Transaction().context["cp_warehouse_id"])
                    for field, loc_id in warehouse_locations.iteritems():
                        if loc_id == location.id:
                            cls.write([cp_warehouse], {field: new_location.id})

            res.append(new_location)
        return res
开发者ID:ferjavrec,项目名称:stock,代码行数:43,代码来源:location.py


注:本文中的trytond.transaction.Transaction.values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。