首先你必须找出你的位置和/或仓库。有足够的可能性做到这一点:
-
-
参照搜索,例如
self.env.ref('my_module.my_location')
-
product.product
_product_available()
# get a recordset of all products
products = self.env['product.product'].search([])
# get a special location (my_location)
location = self.env.ref('my_module.my_location')
quantities = products.with_context(location=location.id)._product_available()
# print the quantities
for product_id, quantity_dict in quantities.iteritems():
print product_id
print quantity_dict
同样的情况也可能发生在
with_context(warehouse=warehouse.id)
with_context(location=[1,2,3])
,请
with_context(location="My Location")