Commit 791a849a authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: force using ledger=automated

Disable all simulation logic if the automated ledger is not used
parent 070480cc
portal = context.getPortalObject()
kw = {}
select_dict= {'delivery_uid': None}
kw.update(
portal_type='Simulation Movement',
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
# This is an optimisation to help mariadb selecting a better index
simulation_state=['draft', 'planned', None],
left_join_list=select_dict.keys(),
delivery_uid=None
)
context.getPortalObject().portal_catalog.searchAndActivate(
portal.portal_catalog.searchAndActivate(
method_id='SimulationMovement_buildSlapOS',
packet_size=1, # Separate calls to many transactions
method_kw={'tag': tag},
......
......@@ -4,6 +4,7 @@ activate_kw = {
}
portal.portal_catalog.searchAndActivate(
portal_type=portal.getPortalDeliveryTypeList(),
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
causality_state=('building', 'calculating'),
activate_kw=activate_kw,
packet_size=30,
......
portal = context.getPortalObject()
portal_type = context.getDeliveryPortalType()
simulation_state = 'confirmed'
# use catalog to prefetch, but check later in ZODB
return [x.getObject() for x in context.getPortalObject().portal_catalog(
return [x.getObject() for x in portal.portal_catalog(
portal_type=portal_type,
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
# BEWARE: it works only in case of per-tree building
default_destination_section_uid=movement_list[0].getDestinationSectionUid(),
destination_section__uid=movement_list[0].getDestinationSectionUid(),
destination_project__uid=movement_list[0].getDestinationProjectUid(),
simulation_state=simulation_state) if x.getSimulationState() == simulation_state]
......@@ -3,7 +3,10 @@ kw['select_dict']=select_dict
kw['left_join_list']=select_dict.keys()
kw['delivery_uid']=None
kw['group_by']=('uid',)
portal = context.getPortalObject()
kw['ledger__uid'] = portal.portal_categories.ledger.automated.getUid()
if src__==0:
return context.portal_catalog(**kw)
return portal.portal_catalog(**kw)
else:
return context.portal_catalog(src__=1, **kw)
return portal.portal_catalog(src__=1, **kw)
if context.getDelivery() is not None:
# movement build but not indexed, so do nothing
return
if context.getLedger() != 'automated':
return
root_applied_rule = context.getRootAppliedRule()
root_applied_rule_path = root_applied_rule.getPath()
......
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