Commit dcd9e826 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: XXXXXXXXXXXXXXXXXX reduce number of open order expand calls

There is no need to quickly generate the Sale Packing List if no Invoice will be generated.

slapos_accounting: alarm to create new simulation tree from Hosting Subscription

This alarm does not crawl all Open Order, and so, should reduce number of open order calls

slapos_accounting: speed up the first invoice creation
parent 53f607f8
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_simulation_interaction_workflow/script_Base_triggerUpdateOpenOrderSimulation</string>
<string>after_script/portal_workflow/slapos_simulation_interaction_workflow/script_OpenSaleOrder_triggerUpdateOpenOrderSimulation</string>
</tuple>
</value>
</item>
......
from DateTime import DateTime
open_sale_order = state_change['object']
tag = 'script_Base_triggerCreateHostingSubscriptionSimulation'
current_date = DateTime()
# Prevent creating empty applied rule if not simulation movement
# will be created
# Sadly, this is probably nearly for tests which freeze date
start_date = open_sale_order.getStartDate()
if (start_date is not None) and (start_date < current_date):
for open_order_line in open_sale_order.objectValues():
for ob in [open_order_line] + open_order_line.getCellValueList():
for item in ob.getAggregateValueList(portal_type='Hosting Subscription'):
ob.reindexObject(activate_kw={'tag': tag})
item.activate(after_tag=tag, activity='SQLQueue').Base_reindexAndSenseAlarm(['slapos_accounting_create_hosting_subscription_simulation'])
......@@ -60,7 +60,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Base_triggerUpdateOpenOrderSimulation</string> </value>
<value> <string>script_OpenSaleOrder_triggerUpdateOpenOrderSimulation</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
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