Wrong computation of delta to find shortage

On the first loop, get_shortage adds a second times the delta of moves at
current date.

issue4215
review6561002
This commit is contained in:
Cédric Krier
2014-10-06 22:16:59 +02:00
parent fc3c010fe9
commit 364dc3ad93
+10 -9
View File
@@ -177,15 +177,6 @@ class Production:
shortages[product_id].append((current_date, quantity))
current_qties[product_id] += quantity
# Update current quantities
with Transaction().set_context(stock_date_start=current_date,
stock_date_end=current_date):
pbl = Product.products_by_location([location_id],
product_ids, with_childs=True)
for key, qty in pbl.iteritems():
_, product_id = key
current_qties[product_id] += qty
# Remove product with smaller period
while (products_period
and products_period[0][0] <= (current_date - date).days):
@@ -193,6 +184,16 @@ class Production:
product_ids.remove(product.id)
current_date += datetime.timedelta(1)
# Update current quantities with next moves
with Transaction().set_context(forecast=True,
stock_date_start=current_date,
stock_date_end=current_date):
pbl = Product.products_by_location([location_id],
product_ids, with_childs=True)
for key, qty in pbl.iteritems():
_, product_id = key
current_qties[product_id] += qty
return shortages