System preparation
First install ERP5 and some modules, then install erp5_csv_style Business Template. Now create Script (Python) object with id Base_importCsvLine in portal_skins/custom folder with content:
1 if object_property_dict.has_key('uid'):
2 object = context.portal_catalog.getObject(object_property_dict['uid'])
3 else:
4 object = context.newContent()
5
6 # activity doesn't support security rights yet...
7 for key in ['uid','id']:
8 if object_property_dict.has_key(key):
9 object_property_dict.pop(key)
10
11 object.edit(**object_property_dict)
(For now original version of Base_importCsvLine has little problem).
CSV file preparation
Create CSV file, which is like in this example:
Where:
- first two lines containing name of fields, which you would like to import, eg in case of Organisation (TODO: second will be ignored, isn't it?):
- third and next lines are with data, like:
Every line shall be separated with enter. To have special characters in your data:
- replace " with ""
- replace newline-character with TODO
I suggest to replace newline with some special combination of charaters, to made it post-import praseable.
Problems with importing
IMHO the best way to analyze problems is to turn off activities. To do so replace:
1 method(priority=4, activity="SQLQueue", passive_commit=1).Base_importCsvLine(attribute_value_dict)
with
1 context.Base_importCsvLine(attribute_value_dict)
in Base_importCsvFile. (Of course copy it from erp_core skin folder to custom before customization.)
Note: importing take some time. Long time sometimes - in our case it took longer than writing this wiki-page and drinking much of wine (working on Duron 600 with 768MB of RAM).
Special thanks to Tomasz Brzezina for support and testing data.