Commit b651ce6f authored by Romain Courteaud's avatar Romain Courteaud Committed by Kazuhiko Shiozaki

erp5_open_trade: support case where stop_date is defined

parent db5a713e
......@@ -12,8 +12,19 @@ for open_order_line in context.objectValues():
if getattr(item.aq_explicit, 'updateSimulation', None) is not None and \
item not in subscription_item_set:
subscription_item_set.add(item)
# If start_date is in futur, do not look for unreachable period
stop_date = item.getNextPeriodicalDate(max(now, ob.getStartDate()))
# Logic duplicated from SubscriptionItem.py
start_date = ob.getStartDate()
# if there is no stop_date, block the generation
# to today
stop_date = ob.getStopDate()
current_date = start_date
if (start_date == stop_date) or (stop_date is None):
# stop_date seems acquired from start_date
stop_date = now
while current_date < stop_date:
current_date = item.getNextPeriodicalDate(current_date)
# Do not expand subscription item if there is
# no new simulation movement to create
# (expand always reindex the full simulation tree,
......@@ -21,8 +32,8 @@ for open_order_line in context.objectValues():
simulation_movement_list = portal.portal_simulation.getMovementHistoryList(
portal_type='Simulation Movement',
aggregate__uid=item.getUid(),
from_date=stop_date,
at_date=stop_date,
from_date=current_date,
at_date=current_date,
only_accountable=False,
)
if len(simulation_movement_list) == 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment