Add issue8860.diff: stock_forecast does not spread all the quantities

This commit is contained in:
Albert Cervera i Areny 2019-11-23 01:26:09 +01:00
parent 451082ad6f
commit be6665eb7f
2 changed files with 31 additions and 0 deletions

30
issue8860.diff Normal file
View File

@ -0,0 +1,30 @@
diff -r e19cb8ea533a forecast.py
--- a/trytond/trytond/modules/stock_forecast/forecast.py Wed Oct 30 13:23:56 2019 +0100
+++ b/trytond/trytond/modules/stock_forecast/forecast.py Sat Nov 23 01:22:47 2019 +0100
@@ -448,15 +448,23 @@
unit_price, self.uom)
moves = []
- for day, qty in distribution.items():
- if qty == 0.0:
+ pending = self.quantity - self.quantity_executed
+ for day in sorted(distribution.keys(), reverse=True):
+ qty = distribution[day]
+ quantity = qty * self.minimal_quantity
+ if day == 0:
+ quantity = max(quantity, pending)
+ else:
+ quantity = min(quantity, pending)
+ if quantity <= 0.0:
continue
+ pending -= quantity
move = Move()
move.from_location = self.forecast.warehouse.storage_location
move.to_location = self.forecast.destination
move.product = self.product
move.uom = self.uom
- move.quantity = qty * self.minimal_quantity
+ move.quantity = quantity
move.planned_date = from_date + datetime.timedelta(day)
move.company = self.forecast.company
move.currency = self.forecast.company.currency

1
series
View File

@ -37,3 +37,4 @@ issue8752 # [analytic_invoice]
#improve_performance_on_try_assign.diff # [stock] change browse of product to get default_uom to pysql
#issue53451002_1_10001.diff # [stock] Allow configuring which quantity is grouped in compute_quantities_query() needed by stock_number_of_packages Issue7805 (only needed by stock_number_of_packages)
#stock_lot_sled.diff # [stock_lot_sled] Allow configuring which quantity is grouped in compute_quantities_query() needed by stock_number_of_packages
issue8860.diff # [stock_forecast] stock_forecast does not spread all the quantities