Commit 71990822 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Add constraint to configure Business Application on existing modules

parent 934b0fe4
......@@ -26,6 +26,9 @@
<portal_type id="Organisation">
<item>GeographicOrganisation</item>
</portal_type>
<portal_type id="Template Tool">
<item>TemplateToolBusinessApplicationModuleCategoryConstraint</item>
</portal_type>
<portal_type id="Web Site Module">
<item>WebSiteModuleShacacheConstraint</item>
</portal_type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateToolBusinessApplicationModuleCategoryConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>business_application_to_module_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>TemplateTool_checkBusinessApplicationToModuleConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
fixit = True if fixit else False
error_list = []
portal = context.getPortalObject()
portal_categories = portal.portal_categories
# 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"
]],
["crm", [ # Customer Relation Management
"campaign_module",
"event_module",
"system_event_module",
"meeting_module",
"sale_opportunity_module",
"support_request_module",
"regularisation_request_module",
"upgrade_decision_module"
]],
["dms", [ # Knowledge management
"document_ingestion_module",
"test_page_module",
"web_page_module",
"web_site_module"
]],
["pdm", [ # PDM
"software_release_module",
"software_product_module",
"software_publication_module",
"software_licence_module",
"product_module",
"service_module"
]],
["trade", [ # Trade
"internal_order_module",
"internal_packing_list_module",
"internal_supply_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",
"sale_trade_condition_module",
]],
]:
for module_name in 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:
business_application_value = portal_categories.restrictedTraverse("business_application/" + business_application_id)
except KeyError:
if not fixit:
error_list.append("business application %s not found, please update this constraint! (ignored when solving)" % business_application_id)
continue
try:
module.getBusinessApplication(None)
except AttributeError:
raise AttributeError("%s has no business_application category" % (module_name))
if module.getBusinessApplication(None) != business_application_id:
if fixit:
module.setBusinessApplicationValue(business_application_value)
else:
error_list.append("no business application assigned to module %s (Expected: %s | Found: %s)" % (module_name, business_application_id, module.getBusinessApplication(None)))
#return "\n".join(error_list) or "OK"
return error_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>fixit=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateTool_checkBusinessApplicationToModuleConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,4 +9,5 @@ Invitation Token | Url
Memcached Tool | MemcachedToolServerConstraint
OAuth Tool | OAuthToolDefaultSlapOSConnector
Organisation | GeographicOrganisation
Template Tool | TemplateToolBusinessApplicationModuleCategoryConstraint
Web Site Module | WebSiteModuleShacacheConstraint
\ No newline at end of file
......@@ -7,4 +7,5 @@ GeographicOrganisation
WebSiteModuleShacacheConstraint
ShacacheSystemPreference
OAuthToolDefaultSlapOSConnector
CatalogToolNoneCreationDateConstraint
\ No newline at end of file
CatalogToolNoneCreationDateConstraint
TemplateToolBusinessApplicationModuleCategoryConstraint
\ 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