diff --git a/product.py b/product.py index 570266a..940fa7f 100644 --- a/product.py +++ b/product.py @@ -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,))