changeset 1d9afc37cde3 in modules/stock:5.0
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=1d9afc37cde3
description:
        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
        (grafted from fd2a67c576f31c397fcaee32b7cab755f6f27770)
diffstat:

 product.py |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diffs (20 lines):

diff -r 81465f5109b4 -r 1d9afc37cde3 product.py
--- a/product.py        Wed Dec 02 19:36:49 2020 +0100
+++ b/product.py        Wed Dec 23 21:30:49 2020 +0100
@@ -397,7 +397,7 @@
             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:
@@ -406,6 +406,7 @@
                 'stock_date_end': date,
                 'forecast': True,
                 }
+            assert date != date_start
             with Transaction().set_context(**context):
                 quantities[date] = Product.products_by_location(
                     [warehouse_id],

Reply via email to