From aed394fc4c54802f0b7b21528ef3362159e8a0c1 Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Thu, 20 Nov 2008 18:30:41 +0100 Subject: [PATCH] Fix: use absolute contraint on forecast dates (not by product) --- forecast.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/forecast.py b/forecast.py index c79d52f65b..7bb9a4aae4 100644 --- a/forecast.py +++ b/forecast.py @@ -53,7 +53,7 @@ class Forecast(OSV): ] self._error_messages.update({ 'date_overlap': 'You can not create forecasts for the same ' - 'product with overlaping dates' + 'locations with overlapping dates' }) self._order.insert(0, ('from_date', 'DESC')) self._order.insert(1, ('location', 'ASC')) @@ -83,19 +83,19 @@ class Forecast(OSV): for forecast in self.browse(cursor, user, ids): if forecast.state != 'done': continue - cursor.execute('SELECT f.id ' \ - 'FROM stock_forecast f ' \ - 'JOIN stock_forecast_line l on (f.id = l.forecast) ' - 'WHERE ((f.from_date <= %s AND f.to_date >= %s) ' \ - 'OR (f.from_date <= %s AND f.to_date >= %s) ' \ - 'OR (f.from_date >= %s AND f.to_date <= %s)) ' \ - 'AND l.product in (%s) ' \ + cursor.execute('SELECT id ' \ + 'FROM stock_forecast ' \ + 'WHERE ((from_date <= %s AND to_date >= %s) ' \ + 'OR (from_date <= %s AND to_date >= %s) ' \ + 'OR (from_date >= %s AND to_date <= %s)) ' \ + 'AND location = %s ' \ + 'AND destination = %s ' \ 'AND state = \'done\' ' \ - 'AND f.id != %s', + 'AND id != %s', (forecast.from_date, forecast.from_date, forecast.to_date, forecast.to_date, forecast.from_date, forecast.to_date, - ",".join((str(l.product.id) for l in forecast.lines)), + forecast.location.id, forecast.destination.id, forecast.id)) if cursor.rowcount: return False