def get_quantity(self, name):
pool = Pool()
Date = pool.get('ir.date')
Location = pool.get('stock.location')
Product = pool.get('product.product')
locations = Location.search([('type', '=', 'storage')])
Transaction().set_context({'locations': [l.id for l in locations]})
context = {}
context['stock_date_end'] = Date.today()
Transaction().set_context(context)
pbl = Product.products_by_location(
location_ids=Transaction().context['locations'],
product_ids=[self.name.id], with_childs=True)
quantity = 0.00
if pbl.values():
quantity = reduce(lambda x, y: x + y, pbl.values())
return quantity
评论列表
文章目录