Commit 2b3efdb4 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: alarm to validate submitted Subscription Request

parent 6d47c032
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_validateSubmittedSubscriptionRequest</string> </value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_subscription_request_validate_submitted</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1677632460.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Validate submitted Subscription Request</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
method_id='SubscriptionRequest_validateIfSubmitted',
# Project are created only from UI for now
portal_type=["Subscription Request"],
simulation_state='submitted',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
<?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>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_validateSubmittedSubscriptionRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
subscription_request = context
portal = context.getPortalObject()
item = subscription_request.getAggregateValue()
if item is None:
resource = subscription_request.getResourceValue()
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',
)
item.validate()
# and create default assignments for the user
# who can manage compute nodes and create instances
customer.newContent(
portal_type='Assignment',
destination_project_value=item,
function='production/manager'
).open()
customer.newContent(
portal_type='Assignment',
destination_project_value=item,
function='customer'
).open()
sale_trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='seller_project_%s' % item.getTitle(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
destination_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",
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',),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(),)
)"""
sale_trade_condition.validate()
else:
raise ValueError('Unsupported resource: %s' % resource.getRelativeUrl())
else:
raise ValueError('Unsupported resource: %s' % resource.getRelativeUrl())
# Use list setter, to ensure it crashes if item is still None
subscription_request.setAggregateValueList([item])
subscription_request.SubscriptionRequest_createOpenSaleOrder()
subscription_request.validate()
subscription_request.invalidate()
<?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_validateIfSubmitted</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -8,5 +8,6 @@ accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transact ...@@ -8,5 +8,6 @@ accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transact
accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transaction/** accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transaction/**
portal_alarms/slapos_subscription_request_create_from_orphaned_item portal_alarms/slapos_subscription_request_create_from_orphaned_item
portal_alarms/slapos_subscription_request_process_** portal_alarms/slapos_subscription_request_process_**
portal_alarms/slapos_subscription_request_validate_submitted
portal_alarms/slapos_update_subscription_request_consistency_state portal_alarms/slapos_update_subscription_request_consistency_state
service_module/slapos_reservation_fee_2 service_module/slapos_reservation_fee_2
\ No newline at end of file
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