Commit d892c344 authored by Nicolas Wavrant's avatar Nicolas Wavrant

Merge branch 'nicolas-ledgers' into 'master'

Renaming base category "journal" to "ledger"

Because "journal" is not French, and this base category can be used in different modules.

This merge request also provides a tested method in erp5_upgrader to update the objects using the "journal" category during the post-upgrade.

See merge request !54
parents 13ce944f cfe0c15d
......@@ -41,17 +41,17 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>journal</string>
<string>ledger</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Journal is used to split deliveries of the same type in different subsets.</string> </value>
<value> <string>Ledger is used to split movements, deliveries, or orders of the same type in different subsets. It will replace the "journal" base category which is less generic</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>journal</string> </value>
<value> <string>ledger</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -59,7 +59,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Journal</string> </value>
<value> <string>Ledger</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -19,7 +19,7 @@ gender
grade
group
insurance_coverage
journal
ledger
legal_parent
marital_status
market_segment
......
......@@ -26,7 +26,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>journal_tester</string> </value>
<value> <string>ledger_tester</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -36,13 +36,13 @@
<key> <string>tested_property</string> </key>
<value>
<tuple>
<string>journal</string>
<string>ledger</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>journal divergence tester</string> </value>
<value> <string>ledger divergence tester</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -26,7 +26,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>journal_tester</string> </value>
<value> <string>ledger_tester</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -36,13 +36,13 @@
<key> <string>tested_property</string> </key>
<value>
<tuple>
<string>journal</string>
<string>ledger</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>journal divergence tester</string> </value>
<value> <string>ledger divergence tester</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -41,7 +41,7 @@
<string>destination</string>
<string>source_section</string>
<string>destination_section</string>
<string>journal</string>
<string>ledger</string>
<string>source_project</string>
<string>destination_project</string>
<string>source_payment</string>
......
......@@ -40,12 +40,12 @@
<item>requirement</item>
</portal_type>
<portal_type id="Task">
<item>journal</item>
<item>ledger</item>
<item>predecessor</item>
<item>requirement</item>
</portal_type>
<portal_type id="Task Line">
<item>journal</item>
<item>ledger</item>
<item>requirement</item>
</portal_type>
<portal_type id="Task Module">
......@@ -53,12 +53,12 @@
</portal_type>
<portal_type id="Task Report">
<item>aggregate</item>
<item>journal</item>
<item>ledger</item>
<item>predecessor</item>
<item>requirement</item>
</portal_type>
<portal_type id="Task Report Line">
<item>journal</item>
<item>ledger</item>
<item>requirement</item>
</portal_type>
<portal_type id="Task Report Module">
......
......@@ -89,7 +89,7 @@
<string>my_source_payment</string>
<string>my_destination_reference</string>
<string>my_source_reference</string>
<string>my_view_mode_journal</string>
<string>my_view_mode_ledger</string>
<string>my_view_mode_task_line_aggregate_title</string>
<string>my_view_mode_listbox_aggregate</string>
<string>my_view_mode_aggregate_title</string>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_view_mode_journal</string> </value>
<value> <string>my_view_mode_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -85,7 +85,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Journal</string> </value>
<value> <string>Ledger</string> </value>
</item>
</dictionary>
</value>
......
......@@ -106,8 +106,8 @@
<string>Reference</string>
</tuple>
<tuple>
<string>journal_translated_title</string>
<string>Journal</string>
<string>ledger_translated_title</string>
<string>Ledger</string>
</tuple>
<tuple>
<string>outcome_description</string>
......@@ -194,8 +194,8 @@
<string>Region</string>
</tuple>
<tuple>
<string>journal</string>
<string>Journal</string>
<string>ledger</string>
<string>Ledger</string>
</tuple>
<tuple>
<string>validated_project_domain</string>
......@@ -255,8 +255,8 @@
<string>Region</string>
</tuple>
<tuple>
<string>journal</string>
<string>Journal</string>
<string>ledger</string>
<string>Ledger</string>
</tuple>
</list>
</value>
......
......@@ -109,8 +109,8 @@
<string>Reference</string>
</tuple>
<tuple>
<string>journal_translated_title</string>
<string>Journal</string>
<string>ledger_translated_title</string>
<string>Ledger</string>
</tuple>
<tuple>
<string>outcome_description</string>
......@@ -205,8 +205,8 @@
<string>Region</string>
</tuple>
<tuple>
<string>journal</string>
<string>Journal</string>
<string>ledger</string>
<string>Ledger</string>
</tuple>
<tuple>
<string>validated_project_domain</string>
......@@ -266,8 +266,8 @@
<string>Region</string>
</tuple>
<tuple>
<string>journal</string>
<string>Journal</string>
<string>ledger</string>
<string>Ledger</string>
</tuple>
<tuple>
<string>preferred_group_person_list_domain</string>
......
......@@ -117,7 +117,7 @@
<string>my_stop_date</string>
<string>my_total_price</string>
<string>my_price_currency</string>
<string>my_journal</string>
<string>my_ledger</string>
<string>my_comment</string>
<string>my_translated_simulation_state_title</string>
<string>my_translated_causality_state_title</string>
......
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_journal</string> </value>
<value> <string>my_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -71,7 +71,7 @@
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_journal</string> </value>
<value> <string>my_view_mode_ledger</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
......
......@@ -119,7 +119,7 @@
<string>my_task_line_price</string>
<string>my_total_price</string>
<string>my_price_currency</string>
<string>my_journal</string>
<string>my_ledger</string>
<string>my_translated_simulation_state_title</string>
</list>
</value>
......
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_journal</string> </value>
<value> <string>my_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -71,7 +71,7 @@
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_journal</string> </value>
<value> <string>my_view_mode_ledger</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
......
......@@ -16,16 +16,16 @@ Sale Order Milestone | requirement
Sale Order | requirement
Sale Packing List Line | predecessor
Sale Packing List Line | requirement
Task Line | journal
Task Line | ledger
Task Line | requirement
Task Module | business_application
Task Report Line | journal
Task Report Line | ledger
Task Report Line | requirement
Task Report Module | business_application
Task Report | aggregate
Task Report | journal
Task Report | ledger
Task Report | predecessor
Task Report | requirement
Task | journal
Task | ledger
Task | predecessor
Task | requirement
\ No newline at end of file
......@@ -99,10 +99,10 @@
<string>my_dialog_mode_at_date</string>
<string>my_dialog_mode_from_date</string>
<string>my_dialog_mode_simulation_state_list</string>
<string>my_dialog_mode_journal</string>
<string>my_dialog_mode_ledger</string>
<string>my_report_mode_at_date</string>
<string>my_report_mode_from_date</string>
<string>my_report_mode_journal</string>
<string>my_report_mode_ledger</string>
<string>my_report_mode_simulation_state_list</string>
<string>my_dialog_mode_multiplier</string>
<string>my_report_mode_multiplier</string>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_dialog_mode_journal</string> </value>
<value> <string>my_dialog_mode_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -85,7 +85,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Journal</string> </value>
<value> <string>Ledger</string> </value>
</item>
</dictionary>
</value>
......
......@@ -19,7 +19,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_report_mode_journal</string> </value>
<value> <string>my_report_mode_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -122,7 +122,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Journal</string> </value>
<value> <string>Ledger</string> </value>
</item>
</dictionary>
</value>
......@@ -138,7 +138,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.journal</string> </value>
<value> <string>python: here.ledger</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -58,8 +58,8 @@ if multiplier in (None, \'\'):\n
inventory_kw["at_date"] = at_date\n
inventory_kw["from_date"] = from_date\n
inventory_kw["quantity"] = "<0"\n
if journal:\n
inventory_kw["parent_journal_relative_url"] = "journal/%s" % journal\n
if ledger:\n
inventory_kw["parent_ledger_relative_url"] = "ledger/%s" % ledger\n
if multiplier is None:\n
multiplier = 1\n
\n
......@@ -120,11 +120,11 @@ if len(summary_dict):\n
for item_url in summary_dict[person_uid].keys():\n
task_report_module_url = "%s/task_report_module/view?reset:int=1&default_source_uid=%s&title=%%" % (absolute_url, person_uid)\n
if item_url == "None":\n
task_report_module_url += "&child_aggregate_relative_url=%%3dNULL&left_join_list=child_aggregate_relative_url&journal_relative_url=journal/%s" % \\\n
(journal, )\n
task_report_module_url += "&child_aggregate_relative_url=%%3dNULL&left_join_list=child_aggregate_relative_url&ledger_relative_url=ledger/%s" % \\\n
(ledger, )\n
else:\n
task_report_module_url += "&child_aggregate_relative_url=%s&journal_relative_url=journal/%s" % \\\n
(item_url, journal)\n
task_report_module_url += "&child_aggregate_relative_url=%s&ledger_relative_url=ledger/%s" % \\\n
(item_url, ledger)\n
person.edit(**{"%s_column_url" % item_url: task_report_module_url})\n
person.setProperty("getColumnUrl", getColumnUrl)\n
listbox_line_list.append(person)\n
......@@ -158,7 +158,7 @@ context = context.asContext(column_list=column_list,\n
from_date=from_date,\n
simulation_state_list=simulation_state_list,\n
column_url_script_list=column_url_script_list,\n
journal=journal,\n
ledger=ledger,\n
multiplier=multiplier,\n
listbox_line_list=listbox_line_list)\n
\n
......@@ -171,7 +171,7 @@ return context.ResearchItemModule_viewResearchSummaryReportData()\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>at_date=None, from_date=None, simulation_state_list=None, journal=None, multiplier=None, batch_mode=False, **kw</string> </value>
<value> <string>at_date=None, from_date=None, simulation_state_list=None, ledger=None, multiplier=None, batch_mode=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -82,7 +82,7 @@
<key> <string>right</string> </key>
<value>
<list>
<string>your_journal</string>
<string>your_ledger</string>
<string>your_simulation_state_list</string>
</list>
</value>
......
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_journal</string> </value>
<value> <string>your_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -71,7 +71,7 @@
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_report_mode_journal</string> </value>
<value> <string>my_dialog_mode_ledger</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
......
......@@ -105,7 +105,7 @@
<key> <string>right</string> </key>
<value>
<list>
<string>my_journal</string>
<string>my_ledger</string>
<string>my_simulation_state_list</string>
</list>
</value>
......
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_journal</string> </value>
<value> <string>my_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -71,7 +71,7 @@
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_dialog_mode_journal</string> </value>
<value> <string>my_report_mode_ledger</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
......
......@@ -40,10 +40,10 @@ class TestResearchItemSummaryReport(TestTaskReportingMixin):
"""Make sure to initialize needed categories
"""
super(TestResearchItemSummaryReport, self).afterSetUp()
journal_base_category = self.portal.portal_categories.journal
ledger_base_category = self.portal.portal_categories.ledger
for category_id in ("operation", "research"):
if not journal_base_category.has_key(category_id):
journal_base_category.newContent(
if not ledger_base_category.has_key(category_id):
ledger_base_category.newContent(
portal_type='Category', title=category_id.title(),
reference=category_id, id=category_id)
......@@ -71,7 +71,7 @@ class TestResearchItemSummaryReport(TestTaskReportingMixin):
source_project='project_module/Project_1/Line_1',
start_date=DateTime('2013/01/10'),
stop_date=DateTime('2013/02/15'),
journal="research",
ledger="research",
simulation_state="confirmed",
**kw)
return task
......@@ -83,7 +83,7 @@ class TestResearchItemSummaryReport(TestTaskReportingMixin):
report = self.portal.research_item_module.ResearchItemModule_callResearchSummaryReport
def callReport():
return report(from_date=from_date, at_date=at_date, batch_mode=True,
journal="research", simulation_state_list=["confirmed"])
ledger="research", simulation_state_list=["confirmed"])
def getDataResult(result):
data_list = []
column_id_list = [x[0] for x in result.column_list]
......
<property_sheet_list>
<portal_type id="Template Tool">
<item>TemplateToolBusinessTemplateInstallationConstraint</item>
<item>TemplateToolCategoryNameConstraint</item>
<item>TemplateToolTableConsistencyConstraint</item>
<item>TemplateToolWorkflowChainConsistencyConstraint</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>TemplateToolCategoryNameConstraint</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>category_name_consistency_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_checkCategoryNameConsistency</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>
<?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>_body</string> </key>
<value> <string>"""\n
This script should returns a list of tuples, each containing 2 elements \n
- The current name of the category, which was set before the upgrade\n
- The new name of the category\n
"""\n
\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getUpgradeCategoryNameList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
updateRelatedCategory = portal.portal_categories.updateRelatedCategory\n
\n
new_category_list = []\n
object_category_list = context.getCategoriesList()\n
\n
new_category_name = kw[\'new_category_name\']\n
old_category_name = kw[\'old_category_name\']\n
\n
for category in object_category_list:\n
new_category = updateRelatedCategory(category, old_category_name, new_category_name)\n
new_category_list.append(new_category)\n
\n
if new_category_list != object_category_list:\n
context.setCategoriesList(new_category_list)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=0, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_updateRelatedCategory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>_body</string> </key>
<value> <string># This script is called as a "script constraint"\n
# It will replace an old base category name by a new name, and update all\n
# related objects.\n
# To get the list of changes, we use the same idea as in TemplateTool_checkBusinessTemplateInstallation :\n
# we get a list of tuples containing the old names and new names from a Script (Python),\n
# which should be overriden in the custom sites\' upgraders.\n
# Because this script is called during the post-upgrade phase, we are\n
# looking for the category by its new name.\n
\n
portal = context.getPortalObject()\n
\n
error_list = []\n
\n
upgrade_list = context.Base_getUpgradeCategoryNameList()\n
\n
if not upgrade_list:\n
return []\n
\n
for old_category_name, new_category_name in upgrade_list:\n
\n
sensitive_portal_type_list = []\n
\n
# We gather portal types having the new category defined as a property\n
for portal_type in portal.portal_types.listTypeInfo():\n
if new_category_name in portal_type.getInstancePropertyAndBaseCategoryList():\n
sensitive_portal_type_list.append(portal_type.getId())\n
\n
# if sensitive_portal_type_list is empty, we don\'t want to check all objects\n
if fixit and sensitive_portal_type_list:\n
context.portal_catalog.searchAndActivate(\'Base_updateRelatedCategory\',\n
activate_kw=activate_kw,\n
portal_type=sensitive_portal_type_list,\n
method_kw={\'fixit\': fixit,\n
\'old_category_name\': old_category_name,\n
\'new_category_name\': new_category_name,}\n
)\n
\n
for portal_type in sensitive_portal_type_list:\n
error_list.append(\'Portal Type %s still contains the category %s\' % (portal_type, old_category_name))\n
\n
return error_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateTool_checkCategoryNameConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -70,9 +70,10 @@ class TestUpgrader(ERP5TypeTestCase):
# update the bt5list will be updated to the version of the filesystem
bootstrap_path = os.environ.get('erp5_tests_bootstrap_path') or \
ERP5Site.getBootstrapDirectory()
bt5_path_list = os.environ['erp5_tests_bt5_path']
repository_list = [bt5_path_list, ]
genbt5list(dir_list=[bootstrap_path, bt5_path_list])
# the path list can contain several directories in projects
bt5_path_list = os.environ['erp5_tests_bt5_path'].split(',')
bt5_path_list.append(bootstrap_path)
genbt5list(dir_list=bt5_path_list)
self.tic()
def stepClearCache(self, sequence=None):
......@@ -433,6 +434,58 @@ class TestUpgrader(ERP5TypeTestCase):
self.fail("checkConsistency should not raise exception."
"It means that one Business Template was not found in repositories")
def stepCreateOrganisationWithActivity(self, sequence=None):
new_organisation = self.portal.organisation_module.newContent(
portal_type="Organisation",
title="Active Organisation",
activity="education")
self.tic()
self.assertEqual(new_organisation.getCategoriesList(),
['activity/education'])
sequence.set('organisation', new_organisation)
def stepCreateCustomUpgradeCategoryList(self, sequence=None):
portal = self.portal
skin_folder = portal.portal_skins.custom
script_id = "Base_getUpgradeCategoryNameList"
skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(script_id)
custom_script = getattr(skin_folder, script_id)
script_body = "return (('activity', 'business_core'),)"
custom_script.ZPythonScript_edit('', script_body)
def stepRemoveCustomUpgradeCategoryList(self, sequence=None):
custom_folder = self.portal.portal_skins.custom
custom_folder.manage_delObjects("Base_getUpgradeCategoryNameList")
def stepRenameCategoryActivityToBusinessCore(self, sequence=None):
"""Renames the category 'activity' to 'business_core'"""
self.portal.portal_categories.activity.edit(
id="business_core",
title="Business Core")
def stepUpdateOrganisationPropertySheetManually(self, sequence=None):
"""
Changes the category property Activity of an Organisation to Business Core.
This step is made manually in the step, but in a real case the old property
sheet would be replaced by a new one saved in a business template to upgrade
"""
activity = self.portal.portal_property_sheets.Organisation.activity_category
activity.edit(id="business_core_category",
title= "business_core",
reference="business_core")
def stepCheckOrganisationObjectUpdated(self, sequence=None):
self.assertEqual(sequence.get('organisation').getCategoriesList(),
['business_core/education'])
def stepCheckPostUpgradeCategoryName(self, sequence=None):
alarm = getattr(self.portal.portal_alarms, 'upgrader_check_post_upgrade')
active_process = alarm.getLastActiveProcess()
detail_list = active_process.getResultList()[0].detail
message = 'Portal Type Organisation still contains the category activity'
self.assertTrue(message in detail_list, detail_list)
self.assertTrue(detail_list.count(message), 1)
def test_workflow_chain_constraint(self):
""" Check if Workflow chains is broken, it can be detected and fixed after
upgrade"""
......@@ -632,3 +685,25 @@ class TestUpgrader(ERP5TypeTestCase):
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_rename_category(self):
"""Check that the renaming category feature correctly updates objects"""
sequence_list = SequenceList()
sequence_string = """
stepCreateOrganisationWithActivity
stepCreateCustomUpgradeCategoryList
stepRenameCategoryActivityToBusinessCore
stepUpdateOrganisationPropertySheetManually
stepTic
stepActiveSensePreUpgradeAlarm
stepActiveSensePostUpgradeAlarm
stepTic
stepRunUpgrader
stepTic
stepRunPostUpgrade
stepTic
stepCheckOrganisationObjectUpdated
stepRemoveCustomUpgradeCategoryList
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
Template Tool | TemplateToolBusinessTemplateInstallationConstraint
Template Tool | TemplateToolCategoryNameConstraint
Template Tool | TemplateToolTableConsistencyConstraint
Template Tool | TemplateToolWorkflowChainConsistencyConstraint
TemplateToolBusinessTemplateInstallationConstraint
TemplateToolWorkflowChainConsistencyConstraint
TemplateToolCategoryNameConstraint
TemplateToolTableConsistencyConstraint
TemplateToolWorkflowChainConsistencyConstraint
......@@ -43,7 +43,7 @@ query_table="catalog"</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_related_parent_journal</string> </value>
<value> <string>z_related_parent_ledger</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
......@@ -57,7 +57,7 @@ query_table="catalog"</string> </value>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-var table_0>.base_category_uid = <dtml-var "portal_categories.journal.getUid()">\n
<dtml-var table_0>.base_category_uid = <dtml-var "portal_categories.ledger.getUid()">\n
AND <dtml-var table_1>.uid = <dtml-var table_0>.category_uid\n
<dtml-var RELATED_QUERY_SEPARATOR>\n
<dtml-var table_0>.uid = <dtml-var query_table>.parent_uid
......
......@@ -17,7 +17,7 @@
<key>parent_description | catalog/description/z_related_parent</key>
<key>parent_float_index | catalog/float_index/z_related_parent</key>
<key>parent_int_index | catalog/int_index/z_related_parent</key>
<key>parent_journal_relative_url | category,catalog/relative_url/z_related_parent_journal</key>
<key>parent_ledger_relative_url | category,catalog/relative_url/z_related_parent_ledger</key>
<key>parent_portal_type | catalog/portal_type/z_related_parent</key>
<key>parent_reference | catalog/reference/z_related_parent</key>
<key>parent_relative_url | catalog/relative_url/z_related_parent</key>
......
......@@ -91,7 +91,7 @@ erp5_mysql_innodb/z_related_mirror_section_uid_from_stock
erp5_mysql_innodb/z_related_node_uid_from_item
erp5_mysql_innodb/z_related_node_uid_from_stock
erp5_mysql_innodb/z_related_parent
erp5_mysql_innodb/z_related_parent_journal
erp5_mysql_innodb/z_related_parent_ledger
erp5_mysql_innodb/z_related_parent_specialise
erp5_mysql_innodb/z_related_parent_strict_group
erp5_mysql_innodb/z_related_payment_request_uid_from_stock
......
......@@ -60,7 +60,7 @@ parent_specialise_reference | category,catalog/reference/z_related_parent_specia
predicate_category_base_category_uid | predicate_category/base_category_uid/z_related_predicate_category
predicate_category_category_strict_membership | predicate_category/category_strict_membership/z_related_predicate_category
predicate_category_category_uid | predicate_category/category_uid/z_related_predicate_category
parent_journal_relative_url | category,catalog/relative_url/z_related_parent_journal
parent_ledger_relative_url | category,catalog/relative_url/z_related_parent_ledger
child_aggregate_relative_url | catalog,category,catalog/relative_url/z_related_child_aggregate
children_reference | catalog/reference/z_related_children
related_resource_from_use_category_uid | category,category/category_uid/z_related_resource_from_use
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>journal_category</string> </value>
<value> <string>ledger_category</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
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