Commit 6eef0707 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: only automate packing list with automated ledger

parent 864aa413
portal = context.getPortalObject() portal = context.getPortalObject()
trade_condition_uid_list = []
root_trade_condition_uid_list = [
portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid(),
portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSaleTradeCondition()).getUid()]
trade_condition_uid_list.extend(root_trade_condition_uid_list)
trade_condition_uid_list.extend([
i.uid for i in portal.ERP5Site_searchRelatedInheritedSpecialiseList(
specialise_uid=root_trade_condition_uid_list,
validation_state="validated")])
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type='Sale Packing List', portal_type='Sale Packing List',
simulation_state='started', simulation_state='started',
causality_state='solved', causality_state='solved',
specialise_uid=trade_condition_uid_list, ledger__uid=portal.portal_categories.ledger.automated.getUid(),
method_id='Delivery_deliverStartedAggregatedSalePackingList', method_id='Delivery_deliverStartedAggregatedSalePackingList',
activate_kw={'tag': tag}, activate_kw={'tag': tag},
) )
......
...@@ -4,30 +4,10 @@ if context.getPortalType() != 'Sale Packing List': ...@@ -4,30 +4,10 @@ if context.getPortalType() != 'Sale Packing List':
raise TypeError('Incorrect delivery.') raise TypeError('Incorrect delivery.')
isTransitionPossible = portal.portal_workflow.isTransitionPossible isTransitionPossible = portal.portal_workflow.isTransitionPossible
if context.getSimulationState() == 'started' \ if context.getSimulationState() == 'started' \
and context.getLedger() == 'automated'\
and len(context.checkConsistency()) == 0 \ and len(context.checkConsistency()) == 0 \
and context.getCausalityState() == 'solved': and context.getCausalityState() == 'solved':
if context.getSpecialise() not in [
portal.portal_preferences.getPreferredAggregatedSaleTradeCondition(),
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()]:
trade_condition_uid_list = []
# search for user specific trade conditions
root_trade_condition_uid_list = [
portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid(),
portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSaleTradeCondition()).getUid()]
trade_condition_uid_list.extend(root_trade_condition_uid_list)
trade_condition_uid_list.extend([
i.uid for i in portal.ERP5Site_searchRelatedInheritedSpecialiseList(
specialise_uid=root_trade_condition_uid_list,
validation_state="validated")])
if context.getSpecialiseUid() not in trade_condition_uid_list:
return
comment = 'Delivered by alarm as all actions in started state are ready.' comment = 'Delivered by alarm as all actions in started state are ready.'
if isTransitionPossible(context, 'stop'): if isTransitionPossible(context, 'stop'):
context.stop(comment=comment) context.stop(comment=comment)
......
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