本文整理汇总了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
示例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