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 8704dc1318
commit f6f91a9375
1 changed files with 3 additions and 2 deletions

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
@ -32,7 +33,7 @@ class Product(metaclass=PoolMeta):
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
@ -40,7 +41,7 @@ class Product(metaclass=PoolMeta):
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 = list(map(int, products))
return cls._get_quantity(products, name, location_ids,
grouping_filter=(products_ids,))