Commit cfc7ae3c authored by Jérome Perrin's avatar Jérome Perrin

Repair script to import Accounting Plan from CSV file, and move configurable

parts in the dialog.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14116 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 37473493
...@@ -86,7 +86,6 @@ def convertToUpperCase(key):\n ...@@ -86,7 +86,6 @@ def convertToUpperCase(key):\n
return result\n return result\n
\n \n
\n \n
\n
def splitCsvLine(str_line):\n def splitCsvLine(str_line):\n
unclean_list = []\n unclean_list = []\n
pieces_of_line = str_line.split(\',\')\n pieces_of_line = str_line.split(\',\')\n
...@@ -139,7 +138,6 @@ csv_title_list = splitCsvLine(csv_line_list[1])\n ...@@ -139,7 +138,6 @@ csv_title_list = splitCsvLine(csv_line_list[1])\n
for csv_line in csv_line_list[2:]:\n for csv_line in csv_line_list[2:]:\n
object = {}\n object = {}\n
csv_data_list = splitCsvLine(csv_line)\n csv_data_list = splitCsvLine(csv_line)\n
\n
data_n = 0\n data_n = 0\n
\n \n
for property in csv_property_list:\n for property in csv_property_list:\n
...@@ -149,29 +147,24 @@ for csv_line in csv_line_list[2:]:\n ...@@ -149,29 +147,24 @@ for csv_line in csv_line_list[2:]:\n
object_list.append(object)\n object_list.append(object)\n
\n \n
\n \n
\n for object in object_list:\n
root_path = \'gap/france/m14\'\n description = object.get(\'Description\', None) or \'\'\n
\n gap = object.get(\'Gap\', None) or \'\'\n
for object in object_list: \n title = object.get(\'Title\', None) or \'\'\n
description = object.get(\'Description\', None) or None\n gap = str(gap)\n
gap = object.get(\'Gap\', None) or None\n
title = object.get(\'Title\', None) or None\n
if gap:\n if gap:\n
gap = gap.replace(\'CLASSE \', \'\')\n gap = gap.replace(\'CLASSE \', \'\')\n
print \'%s - %s - %s\' % (gap or \'\', title or \'\', description or \'\')\n print \'%s - %s - %s\' % (gap or \'\', title or \'\', description or \'\')\n
root = context.getPortalObject()\n root = context.getPortalObject()\n
root = root.portal_categories.restrictedTraverse(root_path)\n root = root.portal_categories.restrictedTraverse(gap_root_path)\n
b = \'\'\n b = \'\'\n
for a in gap:\n for a in gap:\n
b = b + a\n b = b + a\n
if root.has_key(b):\n if root.has_key(b):\n
root = root[b]\n root = root[b]\n
else: \n else:\n
root = root.newContent(id=b)\n root = root.newContent(id=b)\n
root.edit(title = title or \'\', description = description or \'\')\n root.edit(title=title, description=description)\n
\n
\n
#context.activate(priority=4).Base_importCsvLine(object)\n
\n \n
return printed\n return printed\n
\n \n
...@@ -201,7 +194,7 @@ request[ \'RESPONSE\' ].redirect( redirect_url )\n ...@@ -201,7 +194,7 @@ request[ \'RESPONSE\' ].redirect( redirect_url )\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>import_file, encoding=\'iso-8859-15\', **kw</string> </value> <value> <string>import_file, gap_root_path, encoding=\'iso-8859-15\', **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -221,13 +214,14 @@ request[ \'RESPONSE\' ].redirect( redirect_url )\n ...@@ -221,13 +214,14 @@ request[ \'RESPONSE\' ].redirect( redirect_url )\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>3</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>import_file</string> <string>import_file</string>
<string>gap_root_path</string>
<string>encoding</string> <string>encoding</string>
<string>kw</string> <string>kw</string>
<string>_print_</string> <string>_print_</string>
...@@ -251,11 +245,11 @@ request[ \'RESPONSE\' ].redirect( redirect_url )\n ...@@ -251,11 +245,11 @@ request[ \'RESPONSE\' ].redirect( redirect_url )\n
<string>data_n</string> <string>data_n</string>
<string>property</string> <string>property</string>
<string>_write_</string> <string>_write_</string>
<string>root_path</string>
<string>None</string> <string>None</string>
<string>description</string> <string>description</string>
<string>gap</string> <string>gap</string>
<string>title</string> <string>title</string>
<string>str</string>
<string>root</string> <string>root</string>
<string>b</string> <string>b</string>
<string>a</string> <string>a</string>
......
...@@ -67,8 +67,7 @@ ...@@ -67,8 +67,7 @@
<key> <string>group_list</string> </key> <key> <string>group_list</string> </key>
<value> <value>
<list> <list>
<string>Default</string> <string>center</string>
<string>hidden</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -77,19 +76,15 @@ ...@@ -77,19 +76,15 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>Default</string> </key> <key> <string>center</string> </key>
<value> <value>
<list> <list>
<string>my_import_file</string> <string>your_gap_root_path</string>
<string>explanation</string>
<string>your_import_file</string>
</list> </list>
</value> </value>
</item> </item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.StandardFields</string>
<string>LabelField</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>explanation</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string>File must be a CSV file with a header line containing "Gap" and "Title" columns</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Explanation</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.StandardFields</string>
<string>StringField</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_gap_root_path</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string>gap/country/accounting_standart</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>30</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gap Root Path</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_import_file</string> </value> <value> <string>your_import_file</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
......
253 254
\ No newline at end of file \ 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