Commit 10901d12 authored by Romain Courteaud's avatar Romain Courteaud

slapos_upgrader: allow to run the migration multiple time

parent 5b6886a6
......@@ -4,40 +4,45 @@ tag = script.id
### Create the bootstrap Trade Condition
currency = portal.restrictedTraverse('currency_module/EUR')
seller_organisation = portal.restrictedTraverse('organisation_module/rapidspace')
business_process = portal.restrictedTraverse('business_process_module/slapos_ultimate_business_process')
# Sale Trade Condition for Tax
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference="Tax/payment for: %s" % currency.getRelativeUrl(),
trade_condition_type="default",
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
price_currency_value=currency
)
sale_trade_condition.newContent(
portal_type="Trade Model Line",
reference="VAT",
resource="service_module/slapos_tax",
base_application="base_amount/invoicing/taxable",
trade_phase="slapos/tax",
price=0.2,
quantity=1.0,
membership_criterion_base_category=('price_currency', 'base_contribution'),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(), 'base_contribution/base_amount/invoicing/taxable')
)
sale_trade_condition.validate()
sale_trade_condition.reindexObject(activate_kw={'tag': tag})
if portal.portal_catalog.getResultValue(
portal_type='Sale Trade Condition',
specialise__uid=business_process.getUid()
) is None:
# Sale Trade Condition for Tax
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference="Tax/payment for: %s" % currency.getRelativeUrl(),
trade_condition_type="default",
# XXX hardcoded
specialise_value=business_process,
price_currency_value=currency
)
sale_trade_condition.newContent(
portal_type="Trade Model Line",
reference="VAT",
resource="service_module/slapos_tax",
base_application="base_amount/invoicing/taxable",
trade_phase="slapos/tax",
price=0.2,
quantity=1.0,
membership_criterion_base_category=('price_currency', 'base_contribution'),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(), 'base_contribution/base_amount/invoicing/taxable')
)
sale_trade_condition.validate()
sale_trade_condition.reindexObject(activate_kw={'tag': tag})
# Create Trade Condition to create Project
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference="Free Virtual Master (%s)" % seller_organisation.getTitle(),
trade_condition_type="virtual_master",
specialise_value=sale_trade_condition,
source_value=seller_organisation,
price_currency_value=currency,
)
sale_trade_condition.validate()
sale_trade_condition.reindexObject(activate_kw={'tag': tag})
# Create Trade Condition to create Project
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference="Free Virtual Master (%s)" % seller_organisation.getTitle(),
trade_condition_type="virtual_master",
specialise_value=sale_trade_condition,
source_value=seller_organisation,
price_currency_value=currency,
)
sale_trade_condition.validate()
sale_trade_condition.reindexObject(activate_kw={'tag': tag})
return context.activate(after_tag=tag).Base_triggerFullSiteMigrationToVirtualMasterStep2()
......@@ -17,14 +17,15 @@ for sql_result in portal.portal_catalog(
portal_type="Subscription Request",
):
subscription_request = sql_result.getObject()
instance_tree = subscription_request.getAggregateValue(portal_type="Instance Tree")
if (instance_tree is not None):
context.log('COUSCOUS %s' % subscription_request.getRelativeUrl())
# Build the list of prices per project/software release
project_guid = instance_tree.getSuccessorValue().getSlaXmlAsDict().get('project_guid', None)
if project_guid is not None:
payable_project_guid_dict[project_guid] = subscription_request.getPriceCurrency()
if subscription_request.getSpecialise('').startswith('subscription_condition'):
instance_tree = subscription_request.getAggregateValue(portal_type="Instance Tree")
if (instance_tree is not None):
context.log('COUSCOUS %s' % subscription_request.getRelativeUrl())
# Build the list of prices per project/software release
project_guid = instance_tree.getSuccessorValue().getSlaXmlAsDict().get('project_guid', None)
if project_guid is not None:
payable_project_guid_dict[project_guid] = subscription_request.getPriceCurrency()
# Delete existing subscription request, which must be recreated later
subscription_request.getParentValue().manage_delObjects(ids=[subscription_request.getId()])
......
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