【发布时间】:2017-03-08 08:10:34
【问题描述】:
我在一个项目中看到一段代码,其中写了以下内容:
move = Move.create({
'name': repair.name,
'product_id': repair.product_id.id,
'product_uom': repair.product_uom.id or repair.product_id.uom_id.id,
'product_uom_qty': repair.product_qty,
'partner_id': repair.address_id.id,
'location_id': repair.location_id.id,
'location_dest_id': repair.location_dest_id.id,
'restrict_lot_id': repair.lot_id.id,
})
moves |= move
moves.action_done()
|= 在这里是什么意思?
【问题讨论】:
-
无论
moves的类型决定它做什么,它都会做。它通常表示“按位或”或“设置联合”并赋值,一般应相当于moves = moves | move -
看起来像 set union operator。大概
Move类重载了它以允许Move类型的操作数 -
仅供参考:
set现在是内置类型:docs.python.org/2/library/stdtypes.html#set -
我不确定这个类是如何与这个操作符交互的。谢谢罗伯。
-
@AChampion 感谢您提供的信息。我正在尝试关注那些运营商。 :)
标签: python python-2.7 odoo odoo-8 odoo-9