Commit 65ba2956 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: use different trade condition for instance and node

parent 65623d72
......@@ -40,6 +40,7 @@ if item.getPortalType() == 'Instance Tree':
'software_type/%s' % software_type.getRelativeUrl()
]
resource_vcl.sort()
project_value = item.getFollowUpValue(portal_type="Project")
elif item.getPortalType() == 'Compute Node':
service = portal.restrictedTraverse('service_module/slapos_compute_node_subscription')
resource_vcl = None
......@@ -59,7 +60,7 @@ if source_decision_value is None:
return
try:
subscription_request = service.Resource_createSubscriptionRequest(source_decision_value, resource_vcl)
subscription_request = service.Resource_createSubscriptionRequest(source_decision_value, resource_vcl, project_value)
except AssertionError, error:
storeWorkflowComment(item, str(error))
return
......
......@@ -4,13 +4,20 @@ resource = context
if subscriber_person_value is None:
raise AssertionError('Can not find a person profile')
project_value = None
source_project_value = None
destination_project_value = None
if resource.getPortalType() == "Software Product":
project_value = resource.getFollowUpValue(portal_type="Project")
source_project_value = project_value
elif resource.getPortalType() == "Service":
if resource.getRelativeUrl() not in (
"service_module/slapos_virtual_master_subscription",
"service_module/slapos_compute_node_subscription"):
if resource.getRelativeUrl() == "service_module/slapos_compute_node_subscription":
if project_value is None:
raise AssertionError('A project is required for %s %s' % (resource.getRelativeUrl(), project_value))
destination_project_value = project_value
elif resource.getRelativeUrl() == "service_module/slapos_virtual_master_subscription":
if project_value is not None:
raise AssertionError('No project is required for %s %s' % (resource.getRelativeUrl(), project_value))
else:
raise NotImplementedError('Unsupported resource: %s' % resource.getRelativeUrl())
else:
raise NotImplementedError('Unsupported resource: %s' % resource.getRelativeUrl())
......@@ -35,7 +42,8 @@ tmp_sale_order = module.newContent(
destination_value=subscriber_person_value,
destination_section=source_section,
#destination_decision_value=source_decision_value,
destination_project_value=project_value,
destination_project_value=destination_project_value,
source_project_value=source_project_value,
ledger_value=portal.portal_categories.ledger.automated,
# XXX XXX destination_project_value=instance_tree.getFollowUpValue(),
)
......@@ -62,7 +70,7 @@ else:
quantity=1
)
if 0:# XXX resource_vcl:
if variation_category_list:
base_id = 'movement'
cell_key = list(tmp_order_line.getCellKeyList(base_id=base_id))[0]
tmp_order_cell = tmp_order_line.newCell(
......@@ -90,6 +98,7 @@ subscription_request = portal.subscription_request_module.newContent(
source_value=subscriber_person_value,
source_section_value=source_section,
source_decision_value=subscriber_person_value,
source_project_value=source_project_value,
start_date=now,
effective_date=now,
resource_value=resource,
......@@ -101,6 +110,7 @@ subscription_request = portal.subscription_request_module.newContent(
specialise_value=tmp_sale_order.getSpecialiseValue(),
destination=tmp_sale_order.getSource(),
destination_section=tmp_sale_order.getSourceSection(),
destination_project_value=destination_project_value,
price_currency=tmp_sale_order.getPriceCurrency(),
price=price,
# XXX activate_kw=activate_kw
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>subscriber_person_value, variation_category_list</string> </value>
<value> <string>subscriber_person_value, variation_category_list, project_value</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -7,7 +7,6 @@ if item is None:
customer = subscription_request.getSourceValue()
if resource.getPortalType() == "Service":
if resource.getRelativeUrl() == "service_module/slapos_virtual_master_subscription":
# create the project
item = portal.project_module.newContent(
portal_type='Project',
......@@ -30,7 +29,7 @@ if item is None:
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='seller_project_%s' % item.getTitle(),
reference='node_project_%s' % item.getTitle(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
destination_project_value=item,
......@@ -43,6 +42,23 @@ if item is None:
price_currency_value=subscription_request.getPriceCurrencyValue(),
#payment_condition_payment_mode='test-%s' % self.generateNewId()
)
sale_trade_condition.validate()
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='instance_project_%s' % item.getTitle(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
source_project_value=item,
source_value=subscription_request.getDestinationValue(),
#source_section_value=subscription_request.getDestinationSectionValue(),
#destination_section_value=subscription_request.getDestinationSectionValue(),
#source_section_value=seller_organisation,
#source_payment_value=seller_bank_account,
price_currency_value=subscription_request.getPriceCurrencyValue(),
#payment_condition_payment_mode='test-%s' % self.generateNewId()
)
"""
sale_trade_condition.newContent(
portal_type="Trade Model 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