31 lines
1.3 KiB
Diff
31 lines
1.3 KiB
Diff
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
|