Commit 780ac8aa authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: do not crash if subscription could not be created anymore

parent 696e5d33
......@@ -62,29 +62,33 @@ if 0 < total_price:
else:
project = subscription_request.getSourceProjectValue()
subscription_change_request = subscription_request.getResourceValue().Resource_createSubscriptionRequest(
subscription_request.getDestinationValue(),
# [software_type, software_release],
subscription_request.getVariationCategoryList(),
project,
currency_value=subscription_request.getPriceCurrencyValue(),
temp_object=True,
item_value=item,
causality_value=subscription_request.getCausalityValue()
)
if subscription_change_request.getSpecialise() != subscription_request.getSpecialise():
# We have a matching Trade Condition.
# We can recreate the Subscription Request
try:
subscription_change_request = subscription_request.getResourceValue().Resource_createSubscriptionRequest(
subscription_request.getDestinationValue(),
# [software_type, software_release],
subscription_request.getVariationCategoryList(),
project,
currency_value=subscription_request.getPriceCurrencyValue(),
temp_object=True,
item_value=item,
causality_value=subscription_request.getCausalityValue()
)
subscription_request.cancel(comment='Replaced by %s' % subscription_change_request.getReference())
except AssertionError:
pass
else:
if subscription_change_request.getSpecialise() != subscription_request.getSpecialise():
# We have a matching Trade Condition.
# We can recreate the Subscription Request
subscription_change_request = subscription_request.getResourceValue().Resource_createSubscriptionRequest(
subscription_request.getDestinationValue(),
# [software_type, software_release],
subscription_request.getVariationCategoryList(),
project,
currency_value=subscription_request.getPriceCurrencyValue(),
item_value=item,
causality_value=subscription_request.getCausalityValue()
)
subscription_request.cancel(comment='Replaced by %s' % subscription_change_request.getReference())
return
......
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