Commit 6860d171 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: set trade_condition_type on temporary Sale Order

parent a5e2ebad
...@@ -6,19 +6,23 @@ if subscriber_person_value is None: ...@@ -6,19 +6,23 @@ if subscriber_person_value is None:
source_project_value = None source_project_value = None
destination_project_value = None destination_project_value = None
trade_condition_type = None
item = None item = None
if resource.getPortalType() == "Software Product": if resource.getPortalType() == "Software Product":
source_project_value = project_value source_project_value = project_value
trade_condition_type = "instance_tree"
elif resource.getPortalType() == "Service": elif resource.getPortalType() == "Service":
if resource.getRelativeUrl() == "service_module/slapos_compute_node_subscription": if resource.getRelativeUrl() == "service_module/slapos_compute_node_subscription":
if project_value is None: if project_value is None:
raise AssertionError('A project is required for %s %s' % (resource.getRelativeUrl(), project_value)) raise AssertionError('A project is required for %s %s' % (resource.getRelativeUrl(), project_value))
destination_project_value = project_value destination_project_value = project_value
trade_condition_type = "compute_node"
elif resource.getRelativeUrl() == "service_module/slapos_virtual_master_subscription": elif resource.getRelativeUrl() == "service_module/slapos_virtual_master_subscription":
if project_value is None: if project_value is None:
raise AssertionError('Project is required for %s %s' % (resource.getRelativeUrl(), project_value)) raise AssertionError('Project is required for %s %s' % (resource.getRelativeUrl(), project_value))
item = project_value item = project_value
trade_condition_type = "virtual_master"
else: else:
raise NotImplementedError('Unsupported resource: %s' % resource.getRelativeUrl()) raise NotImplementedError('Unsupported resource: %s' % resource.getRelativeUrl())
else: else:
...@@ -37,6 +41,7 @@ module = portal.portal_trash ...@@ -37,6 +41,7 @@ module = portal.portal_trash
tmp_sale_order = module.newContent( tmp_sale_order = module.newContent(
portal_type='Sale Order', portal_type='Sale Order',
temp_object=True, temp_object=True,
trade_condition_type=trade_condition_type,
start_date=now, start_date=now,
destination_value=subscriber_person_value, destination_value=subscriber_person_value,
destination_section=source_section, destination_section=source_section,
......
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