From c1674aa78942e87f2e2de7681a83333b8d318a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 27 Oct 2009 10:19:07 +0100 Subject: [PATCH] Fix search_quantity to compute product_by_location like get_quantity (transplanted from 21e928e05ca37a6ce97164d0933463fa26922e40) --- product.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/product.py b/product.py index 63b986ba36..050fc0ccbd 100644 --- a/product.py +++ b/product.py @@ -81,15 +81,21 @@ class Product(OSV): if not (context and context.get('locations') and domain): return [] - if (name != 'forecast_quantity') and context.get('stock_date_end'): - if context['stock_date_end'] != date_obj.today(cursor, user, - context=context): - context = context.copy() - del context['stock_date_end'] - if name == 'forecast_quantity' and not context.get('stock_date_end'): + if name == 'quantity' and \ + context.get('stock_date_end') and \ + context.get('stock_date_end') > \ + date_obj.today(cursor, user, context=context): + context = context.copy() - context['stock_date_end'] = datetime.date.max + context['stock_date_end'] = date_obj.today( + cursor, user, context=context) + + if name == 'forecast_quantity': + context = context.copy() + context['forecast'] = True + if not context.get('stock_date_end'): + context['stock_date_end'] = datetime.date.max pbl = self.products_by_location( cursor, user, location_ids=context['locations'], with_childs=True,