Commit 4242deb6 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: only automate packing list with automated ledger

parent 3198a1db
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_type='Sale Packing List',
simulation_state='started',
causality_state='solved',
specialise_uid=trade_condition_uid_list,
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
method_id='Delivery_deliverStartedAggregatedSalePackingList',
activate_kw={'tag': tag},
)
......
......@@ -4,30 +4,10 @@ if context.getPortalType() != 'Sale Packing List':
raise TypeError('Incorrect delivery.')
isTransitionPossible = portal.portal_workflow.isTransitionPossible
if context.getSimulationState() == 'started' \
and context.getLedger() == 'automated'\
and len(context.checkConsistency()) == 0 \
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.'
if isTransitionPossible(context, 'stop'):
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