Get qty with childs and stock_date depends is product field or forecast
#036128
This commit is contained in:
parent
8704dc1318
commit
f6f91a9375
|
@ -1,6 +1,7 @@
|
||||||
# This file is part product_qty module for Tryton.
|
# This file is part product_qty module for Tryton.
|
||||||
# The COPYRIGHT file at the top level of this repository contains
|
# The COPYRIGHT file at the top level of this repository contains
|
||||||
# the full copyright notices and license terms.
|
# the full copyright notices and license terms.
|
||||||
|
import datetime
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ class Product(metaclass=PoolMeta):
|
||||||
Location = pool.get('stock.location')
|
Location = pool.get('stock.location')
|
||||||
Date = pool.get('ir.date')
|
Date = pool.get('ir.date')
|
||||||
|
|
||||||
today = Date.today()
|
stock_date = Date.today() if name == 'product' else datetime.date.max
|
||||||
context = Transaction().context
|
context = Transaction().context
|
||||||
|
|
||||||
# not locations in context
|
# not locations in context
|
||||||
|
@ -40,7 +41,7 @@ class Product(metaclass=PoolMeta):
|
||||||
warehouses = Location.search([('type', '=', 'warehouse')])
|
warehouses = Location.search([('type', '=', 'warehouse')])
|
||||||
location_ids = [w.storage_location.id for w in warehouses]
|
location_ids = [w.storage_location.id for w in warehouses]
|
||||||
with Transaction().set_context(locations=location_ids,
|
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))
|
products_ids = list(map(int, products))
|
||||||
return cls._get_quantity(products, name, location_ids,
|
return cls._get_quantity(products, name, location_ids,
|
||||||
grouping_filter=(products_ids,))
|
grouping_filter=(products_ids,))
|
||||||
|
|
Loading…
Reference in New Issue