Upgrade issue5587 stock supply with issue6152

This commit is contained in:
Raimon Esteve 2016-12-28 11:32:47 +01:00
parent 67540fdf24
commit 96f6f701b8
1 changed files with 20 additions and 13 deletions

View File

@ -68,7 +68,7 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
# fetch quantities on order points
order_points = OrderPoint.search([
('type', '=', 'internal'),
@@ -80,60 +85,68 @@
@@ -80,62 +85,73 @@
else:
product_ids = id2product.keys()
product_ids.sort()
@ -94,10 +94,11 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
- if qty < min_qty:
- key = (provisioning_location.id, location.id, product_id)
- moves[key] = max_qty - qty
+ shipments = []
+ internal_shipments = []
+ date = today
+ end_date = date + lead_time
+ while date <= end_date:
+ shipments = []
+ with Transaction().set_context(forecast=True, stock_date_end=date):
+ pbl = Product.products_by_location(id2location.keys(),
+ product_ids, with_childs=True)
@ -133,6 +134,8 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
- ))
- shipment.save()
- shipments.append(shipment)
- cls.wait(shipments)
- return shipments
+ # Create a list of moves to create
+ moves = {}
+ for location in id2location.itervalues():
@ -185,7 +188,11 @@ diff -r 9a0b5b830df9 trytond/trytond/modules/stock_supply/shipment.py
+ shipment.on_change_with_planned_start_date())
+ shipments.append(shipment)
+ date += datetime.timedelta(1)
+ if shipments:
+ shipments = cls.create([s._save_values for s in shipments])
cls.wait(shipments)
return shipments
+ cls.wait(shipments)
+ internal_shipments += shipments
+ return internal_shipments
class CreateShipmentInternalStart(ModelView):