Commit 8d6e7db0 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: create Open Sale Order from Subscription Request

parent 040aa11c
......@@ -153,4 +153,7 @@ subscription_request.submit()
if len(subscription_request.checkConsistency()) != 0:
raise NotImplementedError(subscription_request.checkConsistency())
subscription_request.SubscriptionRequest_createOpenSaleOrder()
subscription_request.validate()
return subscription_request
portal = context.getPortalObject()
subscription_request = context
activate_kw = None
#######################################################
# Hosting Subscription
hosting_subscription = portal.hosting_subscription_module.newContent(
portal_type="Hosting Subscription",
title="hosting %s" % subscription_request.getTitle(),
#follow_up_value=instance_tree.getFollowUpValue(),
ledger_value=portal.portal_categories.ledger.automated,
)
hosting_subscription.validate()
#######################################################
# Open Sale Order
start_date = hosting_subscription.HostingSubscription_calculateSubscriptionStartDate()
open_sale_order = portal.open_sale_order_module.newContent(
portal_type="Open Sale Order",
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(),
source_value=subscription_request.getDestinationValue(),
source_section_value=subscription_request.getDestinationSectionValue(),
source_decision_value=subscription_request.getDestinationDecisionValue(),
source_project_value=subscription_request.getDestinationProjectValue(),
destination_value=subscription_request.getSourceValue(),
destination_section_value=subscription_request.getSourceSectionValue(),
destination_decision_value=subscription_request.getSourceDecisionValue(),
destination_project_value=subscription_request.getSourceProjectValue(),
ledger_value=portal.portal_categories.ledger.automated,
causality_value=subscription_request,
price_currency_value=subscription_request.getPriceCurrencyValue(),
activate_kw=activate_kw
)
variation_category_list = subscription_request.getVariationCategoryList()
open_order_line = open_sale_order.newContent(
portal_type="Open Sale Order Line",
resource_value=subscription_request.getResourceValue(),
variation_category_list=variation_category_list,
quantity_unit_value=subscription_request.getQuantityUnitValue(),
base_contribution_list=subscription_request.getBaseContributionList(),
use=subscription_request.getUse(),
activate_kw=activate_kw
)
if variation_category_list:
base_id = 'path'
cell_key = list(open_order_line.getCellKeyList(base_id=base_id))[0]
open_order_cell = open_order_line.newCell(
base_id=base_id,
portal_type="Open Sale Order Cell",
*cell_key
)
open_order_cell.edit(
mapped_value_property_list=['price','quantity'],
predicate_category_list=cell_key,
variation_category_list=cell_key,
activate_kw=activate_kw
)
else:
open_order_cell = open_order_line
open_order_cell.edit(
quantity=subscription_request.getQuantity(),
price=subscription_request.getPrice(),
aggregate_value_list=[
hosting_subscription,
subscription_request.getAggregateValue()
],
activate_kw=activate_kw
)
open_sale_order.OpenSaleOrder_updatePeriod()
open_sale_order.plan()
open_sale_order.validate()
return open_sale_order
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SubscriptionRequest_createOpenSaleOrder</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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