Commit 3070f8af authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: archive previous open sale order

parent 1c66186e
......@@ -31,9 +31,9 @@ if open_order_movement is None:
identical_order_base_category_list = [
'specialise',
'destination',
'destination_section',
'destination_decisition',
# 'destination',
# 'destination_section',
# 'destination_decisition',
'destination_project',
'source',
'source_section',
......@@ -43,13 +43,37 @@ identical_order_base_category_list = [
'resource',
'variation_category_list',
'quantity_unit',
'aggregate',
'quantity',
'price'
# 'price'
]
for identical_order_base_category in identical_order_base_category_list:
if open_order_movement.getProperty(identical_order_base_category) != subscription_change_request.getProperty(identical_order_base_category):
return invalidate(subscription_change_request, 'Unhandled requested changes on: %s' % identical_order_base_category)
# Ensure the subscribed item is the same
subscribed_item = open_order_movement.getAggregateValue(portal_type=['Instance Tree', 'Compute Node', 'Project'])
if subscription_change_request.getAggregateUid() != subscribed_item.getUid():
return invalidate(subscription_change_request, 'Unhandled requested changes on: aggregate')
# XXX Compensation
open_sale_order.OpenSaleOrder_archiveIfUnusedItem(check_unused_item=False)
# Create new Open Sale Order
subscription_change_request.SubscriptionRequest_createOpenSaleOrder()
# Change Subscripted Item user if needed
subscribed_item = open_order_movement.getAggregateValue(portal_type=['Instance Tree', 'Compute Node', 'Project'])
if subscribed_item is None:
raise NotImplementedError('Unsupported subscribed item')
elif subscribed_item.getPortalType() == 'Compute Node':
# No user is set on Compute Node
pass
elif subscribed_item.getPortalType() == 'Instance Tree':
subscribed_item.edit(destination_section=subscription_change_request.getDestination())
elif subscribed_item.getPortalType() == 'Instance Tree':
subscribed_item.edit(destination=subscription_change_request.getDestination())
else:
raise NotImplementedError('Not implemented subscribed item')
return invalidate(subscription_change_request, 'Unknown requested changes')
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