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

slapos_upgrader: allow to run the migration multiple time

parent 5b6886a6
...@@ -4,17 +4,22 @@ tag = script.id ...@@ -4,17 +4,22 @@ tag = script.id
### Create the bootstrap Trade Condition ### Create the bootstrap Trade Condition
currency = portal.restrictedTraverse('currency_module/EUR') currency = portal.restrictedTraverse('currency_module/EUR')
seller_organisation = portal.restrictedTraverse('organisation_module/rapidspace') seller_organisation = portal.restrictedTraverse('organisation_module/rapidspace')
business_process = portal.restrictedTraverse('business_process_module/slapos_ultimate_business_process')
# Sale Trade Condition for Tax if portal.portal_catalog.getResultValue(
sale_trade_condition = portal.sale_trade_condition_module.newContent( 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", portal_type="Sale Trade Condition",
reference="Tax/payment for: %s" % currency.getRelativeUrl(), reference="Tax/payment for: %s" % currency.getRelativeUrl(),
trade_condition_type="default", trade_condition_type="default",
# XXX hardcoded # XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process", specialise_value=business_process,
price_currency_value=currency price_currency_value=currency
) )
sale_trade_condition.newContent( sale_trade_condition.newContent(
portal_type="Trade Model Line", portal_type="Trade Model Line",
reference="VAT", reference="VAT",
resource="service_module/slapos_tax", resource="service_module/slapos_tax",
...@@ -24,20 +29,20 @@ sale_trade_condition.newContent( ...@@ -24,20 +29,20 @@ sale_trade_condition.newContent(
quantity=1.0, quantity=1.0,
membership_criterion_base_category=('price_currency', 'base_contribution'), membership_criterion_base_category=('price_currency', 'base_contribution'),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(), 'base_contribution/base_amount/invoicing/taxable') membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(), 'base_contribution/base_amount/invoicing/taxable')
) )
sale_trade_condition.validate() sale_trade_condition.validate()
sale_trade_condition.reindexObject(activate_kw={'tag': tag}) sale_trade_condition.reindexObject(activate_kw={'tag': tag})
# Create Trade Condition to create Project # Create Trade Condition to create Project
sale_trade_condition = portal.sale_trade_condition_module.newContent( sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition", portal_type="Sale Trade Condition",
reference="Free Virtual Master (%s)" % seller_organisation.getTitle(), reference="Free Virtual Master (%s)" % seller_organisation.getTitle(),
trade_condition_type="virtual_master", trade_condition_type="virtual_master",
specialise_value=sale_trade_condition, specialise_value=sale_trade_condition,
source_value=seller_organisation, source_value=seller_organisation,
price_currency_value=currency, price_currency_value=currency,
) )
sale_trade_condition.validate() sale_trade_condition.validate()
sale_trade_condition.reindexObject(activate_kw={'tag': tag}) sale_trade_condition.reindexObject(activate_kw={'tag': tag})
return context.activate(after_tag=tag).Base_triggerFullSiteMigrationToVirtualMasterStep2() return context.activate(after_tag=tag).Base_triggerFullSiteMigrationToVirtualMasterStep2()
...@@ -17,8 +17,9 @@ for sql_result in portal.portal_catalog( ...@@ -17,8 +17,9 @@ for sql_result in portal.portal_catalog(
portal_type="Subscription Request", portal_type="Subscription Request",
): ):
subscription_request = sql_result.getObject() subscription_request = sql_result.getObject()
instance_tree = subscription_request.getAggregateValue(portal_type="Instance Tree")
if subscription_request.getSpecialise('').startswith('subscription_condition'):
instance_tree = subscription_request.getAggregateValue(portal_type="Instance Tree")
if (instance_tree is not None): if (instance_tree is not None):
context.log('COUSCOUS %s' % subscription_request.getRelativeUrl()) context.log('COUSCOUS %s' % subscription_request.getRelativeUrl())
# Build the list of prices per project/software release # Build the list of prices per project/software release
......
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