From fc5b4497ea1b8ad4e6b2ae8fe76d5d63020f16e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 23 Dec 2020 21:30:49 +0100 Subject: [PATCH] Ensure dates are unique When computing the quantity with delta, we must ensure that the start and end dates are always different otherwise the delta quantity is always zero for duplicated days (like today). issue9942 review343181002 --- product.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/product.py b/product.py index bc22b8d580..9e6dc1a692 100644 --- a/product.py +++ b/product.py @@ -529,7 +529,7 @@ class ProductQuantitiesByWarehouse(ModelSQL, ModelView): key = trans_context['product_template'] warehouse_id = trans_context.get('warehouse') - dates = sorted(l.date for l in lines) + dates = sorted({l.date for l in lines}) quantities = {} date_start = None for date in dates: @@ -538,6 +538,7 @@ class ProductQuantitiesByWarehouse(ModelSQL, ModelView): 'stock_date_end': date, 'forecast': True, } + assert date != date_start with Transaction().set_context(**context): quantities[date] = Product.products_by_location( [warehouse_id],