Commit 79c52c51 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: change business_application values

parent c3e00cef
......@@ -3,25 +3,47 @@ error_list = []
portal = context.getPortalObject()
portal_categories = portal.portal_categories
configured_module_name_list = []
# XXX Find a nice way to store the "json", and then create make a generic erp5_upgrader constraint
# Or may be let the configurator set these values, and change this script to check BA against the configurator
for business_application_id, module_name_list in [
["base", [ # Base Data
"currency_module",
"organisation_module",
"person_module",
"access_token_module",
"invitation_token_module",
"credential_request_module"
]],
["accounting", [ # Accounting
"accounting_module",
"account_module"
"account_module",
"currency_module",
]],
["login", [ # Login
"access_token_module",
"credential_request_module",
"credential_recovery_module",
"credential_update_module",
"system_event_module",
]],
["slapos", [ # SlapOS
"cloud_contract_module",
"compute_node_module",
"computer_module",
"computer_model_module",
"computer_network_module",
"consumption_document_module",
"data_set_module",
"hosting_subscription_module",
"instance_tree_module",
"invitation_token_module",
"project_module",
"software_installation_module",
"software_instance_module",
]],
["crm", [ # Customer Relation Management
"campaign_module",
"event_module",
"system_event_module",
"incident_response_module",
"notification_message_module",
"meeting_module",
"sale_opportunity_module",
"support_request_module",
......@@ -29,35 +51,33 @@ for business_application_id, module_name_list in [
"upgrade_decision_module"
]],
["dms", [ # Knowledge management
"document_module",
"document_ingestion_module",
"test_page_module",
"image_module",
"web_page_module",
"web_site_module"
]],
["pdm", [ # PDM
"component_module",
"software_release_module",
"software_product_module",
"software_publication_module",
"software_licence_module",
"product_module",
"service_module"
"service_module",
"transformation_module",
]],
["trade", [ # Trade
"internal_order_module",
"internal_packing_list_module",
"internal_supply_module",
"subscription_request_module",
"subscription_condition_module",
"business_process_module",
"business_configuration_module",
"inventory_module",
"purchase_order_module",
"purchase_packing_list_module",
"purchase_supply_module",
"purchase_trade_condition_module",
"open_purchase_order_module",
"open_sale_order_module",
"open_internal_order_module",
"returned_sale_packing_list_module",
"returned_sale_order_module",
"returned_purchase_packing_list_module",
"returned_purchase_order_module",
"sale_order_module",
"sale_packing_list_module",
"sale_supply_module",
......@@ -65,6 +85,7 @@ for business_application_id, module_name_list in [
]],
]:
for module_name in module_name_list:
configured_module_name_list.append(module_name)
module = getattr(portal, module_name, None)
if module is None:
if not fixit:
......@@ -86,5 +107,23 @@ for business_application_id, module_name_list in [
else:
error_list.append("no business application assigned to module %s (Expected: %s | Found: %s)" % (module_name, business_application_id, module.getBusinessApplication(None)))
# Remove business application from unused module
for module_name in portal.contentIds():
if module_name.endswith("_module") and (module_name not in configured_module_name_list):
module = getattr(portal, module_name, None)
if module is None:
if not fixit:
error_list.append("module %s not found, please update this constraint! (ignored when solving)" % module_name)
continue
try:
module.getBusinessApplication(None)
except AttributeError:
raise AttributeError("%s has no business_application category" % (module_name))
if module.getBusinessApplication(None) != None:
if fixit:
module.setBusinessApplicationValue(None)
else:
error_list.append("no business application assigned to module %s (Expected: None | Found: %s)" % (module_name, module.getBusinessApplication(None)))
#return "\n".join(error_list) or "OK"
return error_list
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