Commit 105ee149 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: do not set the stop_date on the open order

parent 4f0438a0
...@@ -34,14 +34,18 @@ hosting_subscription.validate() ...@@ -34,14 +34,18 @@ hosting_subscription.validate()
####################################################### #######################################################
# Open Sale Order # Open Sale Order
start_date = hosting_subscription.HostingSubscription_calculateSubscriptionStartDate()
open_sale_order = portal.open_sale_order_module.newContent( current_date = getClosestDate(target_date=hosting_subscription.getCreationDate(), precision='day')
portal_type="Open Sale Order", next_period_date = hosting_subscription.getNextPeriodicalDate(current_date)
if subscription_request.getQuantityUnit() == 'time/month':
start_date = addToDate(next_period_date, to_add={'month': -1})
assert hosting_subscription.getNextPeriodicalDate(start_date) == next_period_date
else:
raise ValueError('Unsupported quantity unit %s' % subscription_request.getQuantityUnit())
open_order_edit_kw = dict(
start_date=start_date, start_date=start_date,
# Ensure stop date value is higher than start date
# it will be updated by OpenSaleOrder_updatePeriod
stop_date=start_date + 1,
specialise_value=subscription_request.getSpecialiseValue(), specialise_value=subscription_request.getSpecialiseValue(),
source_value=subscription_request.getDestinationValue(), source_value=subscription_request.getDestinationValue(),
source_section_value=subscription_request.getDestinationSectionValue(), source_section_value=subscription_request.getDestinationSectionValue(),
...@@ -57,6 +61,16 @@ open_sale_order = portal.open_sale_order_module.newContent( ...@@ -57,6 +61,16 @@ open_sale_order = portal.open_sale_order_module.newContent(
activate_kw=activate_kw activate_kw=activate_kw
) )
open_sale_order = portal.open_sale_order_module.newContent(
portal_type="Open Sale Order",
# Do not set the stop_date, as we don't know
# when the user will close the subscription
stop_date=None,
**open_order_edit_kw
)
variation_category_list = subscription_request.getVariationCategoryList() variation_category_list = subscription_request.getVariationCategoryList()
open_order_line = open_sale_order.newContent( open_order_line = open_sale_order.newContent(
portal_type="Open Sale Order Line", portal_type="Open Sale Order Line",
......
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