Commit 06e62455 authored by Romain Courteaud's avatar Romain Courteaud

erp5_open_trade: do not reexpand simulation if there is no simulation movement to create

expand always reindex the full simulation tree, even if there is nothing to do.
This is cpu costly.
parent 7917a3ee
......@@ -3,6 +3,8 @@ if context.checkConsistency():
return
subscription_item_set = set()
now = DateTime().earliestTime()
portal = context.getPortalObject()
for open_order_line in context.objectValues():
for ob in [open_order_line] + open_order_line.getCellValueList():
......@@ -10,4 +12,15 @@ 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)
item.updateSimulation(expand_root=1)
stop_date = item.getNextPeriodicalDate(now)
# Do not expand subscription item if there is
# no new simulation movement to create
# (expand always reindex the full simulation tree,
# which can be cpu costly when we have many hosting subscription)
simulation_movement = portal.portal_catalog.getResultValue(
portal_type="Simulation Movement",
aggregate__uid=item.getUid(),
**{'movement.stop_date': stop_date}
)
if simulation_movement is None:
item.updateSimulation(expand_root=1)
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