Commit 3198a1db authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: only automate invoice with automated ledger

parent 1bbc23f6
from DateTime import DateTime
portal = context.getPortalObject()
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(
portal_type="Sale Trade Condition",
specialise_uid=root_trade_condition_uid_list,
validation_state="validated")])
portal.portal_catalog.searchAndActivate(
portal_type='Sale Invoice Transaction',
simulation_state='confirmed',
causality_state='solved',
specialise__uid=trade_condition_uid_list,
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
method_id='Delivery_stopConfirmedAggregatedSaleInvoiceTransaction',
activate_kw={'tag': tag}
)
......
......@@ -3,32 +3,11 @@ if context.getPortalType() != 'Sale Invoice Transaction':
raise TypeError('Incorrect delivery.')
isTransitionPossible = portal.portal_workflow.isTransitionPossible
if context.getSimulationState() == 'confirmed'\
and context.getLedger() == 'automated'\
and len(context.checkConsistency()) == 0\
and context.getCausalityState() == 'solved'\
and len(context.objectValues(portal_type="Sale Invoice Transaction Line")):
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(
portal_type="Sale Trade Condition",
specialise_uid=root_trade_condition_uid_list,
validation_state="validated")])
if context.getSpecialiseUid() not in trade_condition_uid_list:
return
comment = 'Stopped by alarm as all actions in confirmed state are ready.'
if isTransitionPossible(context, 'start'):
context.start(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