Get qty with childs and stock_date depends is product field or forecast

#036128
This commit is contained in:
Raimon Esteve 2018-12-03 22:00:58 +01:00
parent eed734244a
commit 3e2b3e6019

View file

@ -1,6 +1,7 @@
# This file is part product_qty module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import datetime
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
@ -34,7 +35,7 @@ class Product:
Location = pool.get('stock.location')
Date = pool.get('ir.date')
today = Date.today()
stock_date = Date.today() if name == 'product' else datetime.date.max
context = Transaction().context
# not locations in context
@ -42,7 +43,7 @@ class Product:
warehouses = Location.search([('type', '=', 'warehouse')])
location_ids = [w.storage_location.id for w in warehouses]
with Transaction().set_context(locations=location_ids,
stock_date_end=today, with_childs=True):
stock_date_end=stock_date, with_childs=True):
products_ids = map(int, products)
return cls._get_quantity(products, name, location_ids,
grouping_filter=(products_ids,))