There are different methods to import your data into OpenERP: The best way to import data in OpenERP is to build a module that integrates all the data you want to import. So, when you want to import all the data, you just have to install the module and OpenERP manages the different creation operations.
Create a new module named data_partners. In the __openerp__.py file, the files containing the data should be written within the ‘init_xml’. For example: Here we are importing two files ‘res.partner.csv’ and ‘res.partner.address.csv’. Then, in the __openerp__.py file, write
'init_xml':[ 'res.partner.csv', 'res.partner.address.csv' ]
The module will import two different files:
res.partner.csv : a CSV file containing records of the res.partner object res.partner.address.csv : a CSV file containing records of the res.partner.address object
When you import a .CSV file in OpenERP, you can provide a ‘id’ column that contains a uniq identification number or string for the record. We will use this ‘id’ column to refer to the ID of the record in the original application. As to refer to this record from a many2one field, you can use ‘FIELD_NAME:id’. OpenERP will re-create the relationship between the record using this uniq ID.
Contents of the ‘res.partner.csv’ file
id,name partner_2,ASUStek partner_3,Agrolait partner_4,Camptocamp partner_5,Syleam
Contents of the ‘res.partner.address.csv’ file
id,name,partner_id:id partner_address2,Benoit Mortier,partner_2 partner_address3,Laurent Jacot,partner_3 partner_address4,Laith Jubair,partner_4 partner_address5,Fabien Pinckaers,partner_4
When you will install this module, OpenERP will automatically import the partners and then the address and recreate efficiently the link between the two records. When installing a module, OpenERP will test and apply the constraints for consistency of the data.
If you plan to upload thousands of records through this technique, you should consider using the argument ‘-P’ when running the server.
openerp_server.py -P status.pickle --init=data_partners(module_name)
This method provides a faster importation of the data and, if it crashes in the middle of the import, it will continue at the same line after rerunning the server. This may preserves hours of testing when importing big files.
Anonymous: how to make such module?? like i want to import data of tally in openerp. what are the requirements to make this module??".
Leave a Reply