This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Python CSV to OpenERP importation library

Project Description

csv2oerp is a Python converter from the csv format to OpenERP data record.

csv2oerp is an easy way to import records from heterogeneous datas by editing a simple script as the manner of OpenERP data model. You can specify pre-treatment(s) before any records insertions, you can also, according to criteria, omit the insertion of an entire record, mofify it or just create it (CRUD abilities).

Some features of csv2oerp include abilities of Python csv module to specify input file configuration. It also include somme abilities of some third party library according to your needs.

Quick start

#!/usr/bin/env python
#.. your_script.py
from csv2oerp import Model, Field, Openerp, Session

#
# Configure OpenERP connection
#

oerp = Openerp(
    host='198.168.0.1', port=8069,
    user='admin', pwd='admin', dbname='database',
    lang'fr_FR')

#
# Create a new importation instance::
#

session = Session(
    'file.csv', delimiter=';', quotechar='"', encoding='utf-8',
    offset=1, limit=10)

#
# Define your mapping to link both csv and OpenERP::
#

# res.partner is unique by siren and will not be updated if exists
res_partner = Model('res.partner', fields=[
        Field('name', columns=[1]),
        Field('siren', columns=[2]),
        Field('website', columns=[16]),
    ], update=False, search=['siren'])

# res.country is unique by code and name and will not be updated if exists
res_country = Model('res.country', fields=[
        Field('code', columns=[13], default='FR'),
        Field('name', columns=[13], default='FRANCE'),
    ], update=False, search=['code', 'name'])

# res.partner.address is unique by type and partner_id
res_partner_address = Model('res.partner.address', fields=[

        # Simple fields, some with default value and some unique between records
        Field('zip', columns=[9], default='35000'),
        Field('city', columns=[10], default='RENNES'),
        Field('phone', column=[14]),
        Field('fax', columns=[15]),
        Field('email', columns=[17], unique=True),
        Field('cedex', columns=[68]),

        # Mixing columns (by concatenation or selection)
        Field('street', columns=[7, 6], method='selection'),
        Field('street2', columns=[8, 5], method='concatenate'),

        # Model's relations with res.partner which must exists
        Field('country_id', relation=res_country),
        Field('partner_id', relation=res_partner, required=True),

        # Adding a custom value to a missing field in the `csv` file
        Field('type', custom='delivery'),
    ], search=['type', 'partner_id'])

#
# Finally join objects to the session which starts the import process
#

# There is no particular needs to also inject res.partner model, as it's
# already contained as a relation of res.partner.address
session.bind(oerp, [res_partner_address, ])

#
# Optionaly: show statistics of records's activities during the importation process
#

csv2oerp.show_stats()

Supported Desktop versions

All architectures.

Supported Python versions

csv2oerp support Python versions 2.6 and 2.7.

License

This software is made available under the LGPLv3 license.

Bugs or suggestions

Please, feel free to report bugs or suggestions in the Bug Tracker!

Release History

Release History

This version
History Node

0.7.3

History Node

0.7.2

History Node

0.7.1

History Node

0.7

History Node

0.6.14

History Node

0.6.13

History Node

0.6.12

History Node

0.6.11

History Node

0.6.10

History Node

0.6.9

History Node

0.6.8

History Node

0.6.7

History Node

0.6.6

History Node

0.6.5

History Node

0.6.4

History Node

0.6.3

History Node

0.6.2

History Node

0.6.1

History Node

0.6

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
csv2oerp-0.7.3.tar.gz (48.5 kB) Copy SHA256 Checksum SHA256 Source Feb 23, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting