How to Import data into OpenERP V7

32,194 views

Published on

This presentation is an overview of the "base_import" module in OpenERP. With test driven development and data migration, we need to gather and enter real data owned by users.

Published in: Technology
5 Comments
55 Likes
Statistics
Notes
No Downloads
Views
Total views
32,194
On SlideShare
0
From Embeds
0
Number of Embeds
1,075
Actions
Shares
0
Downloads
0
Comments
5
Likes
55
Embeds 0
No embeds

No notes for slide

How to Import data into OpenERP V7

  1. 1. BEST PRACTICES ON HOW TO IMPORT DATA INTO OPENERP Why you should love CSV Import Cyril MORISSE ( @cmorisse )
  2. 2. Introduction  With Test Driven Development and Data Migration, we need to gather and enter real data owned by users  We need a data format within user’s reach (compared to XML)  As of version 7.0 OpenERP has redesigned the import system (“base_import” module):  It has nearly everything right out of the box  Only missing feature is user oriented documentation  This talk is an overview of the module
  3. 3. Installation  Export functionality is available right out of the box  BUT import functionality must be installed:  Import is covered by “base_import” module  Import must be installed via Settings / Configuration / General Settings  Then “Import” link is available in all list/tree views
  4. 4. CSV import issues  When importing data using CSV, you will face 3 main issues: Identify the fields required for an import Understand “OpenERP External IDs” Understand how to import the different type of fields Simple fields ( date, text, numbers, boolean,…) Relational fields:  Many2many  Many2One  One2many
  5. 5. Identify fields to import  To identify the columns required to import an object: 1. Activate “Developer Mode” 2. Write down all the fields you must enter manually 3. Export a file with all these fields 4. Delete values in the id column then re-import the file to check everything is ok 5. If a column is missing ; do it again from step 3 and add the column
  6. 6. Understand IDs  Example Product categories  CSV Import allows User Defined External IDs  External IDs are symbolic names for records  Format is module_name.id_name
  7. 7. Understand IDs (continued)  User defined IDs are saved in the database and can be retrieved via:  Settings / Technical / Sequences & Identifiers / External Identifiers
  8. 8. Understand IDs (end)  User defined IDs allow to manage Import / Update of data  During import:  If a record exists with this ID, OpenERP will update the record  If no record exists with this ID, OpenERP will create a new record  Export IDs  During Export, OpenERP creates an export ID for all records without IDs (manually created records)  In the database all External IDs are stored in table ir_model_data
  9. 9. Import simple Fields Field type Cell content Example char, text Content surrounded by “ “This is a text ""value”"." float Number with . as decimal separator 3.15 boolean True or False “0” or 0 or “False” or False or “1” or 1 or “True” or True date YYYY-MM-DD 2013-06-10 datetime YYYY-MM-DD HH:MM:SS 2013-06-10 07:07 selection Value as given by “developer mode” inspector reference Value in database is “object,id”
  10. 10. Import relations: Many2One  Many2one  This is the simplest relation to import in CSV  Just use id of referenced object id parent_id product_category ...
  11. 11. Import relations: Many2Many  Eg. Customer Tags  Many2many involves 3 tables  Really simple in CSV ; enter all values separated by comma with no space ... id res_partner id ... res_partner_category category_idpartner_id res_partner_res_partner_category_rel
  12. 12. Import relations: One2Many  Eg. Quotations/ Quotations Lines  In CSV: Enter lines while you don’t repeat header object fields  Child objects column format is “one2many_fieldname/child_object_field” ... id sale_order id order_id sale_order_line ...
  13. 13. Integrate CSV in your development workflow  Create a set of shared Google Spreadsheet that your users will complete with project data  Organize your OpenERP project in 3 modules:  project_core with code and technical parameters  project_data : will contains only data in CSV files  project_test : contains your test code and test specific data  Use a tool to automate export and download of the Google Spreadsheet into the project_data module  http://bitbucket.org/cmorisse/edgdd  Your users will be able to “cooperatively” enter their data and you will be able to seamlessly integrate and use this data in your project
  14. 14. More information? www.audaxis.com Contact us openerp@audaxis.com 14 Visit our booth at OpenERP Community Days in Hall K

×