This module defines the OERP and DMS classes.
The OERP class manage the client-side operations which are related to an OpenERP server. You can use this to write Python programs that performs a variety of automated jobs that communicate with an OpenERP server.
Here’s a sample session using the oerplib module:
>>> import oerplib
>>> oerp = oerplib.OERP('localhost') # connect to localhost, default port
>>> user = oerp.login('admin', 'admin') # login returns an user object
>>> user.name
'Administrator'
Return a new instance of the OERP class. The optional database parameter specifies the default database to use when the login(user, passwd) is called. By default, the port 8069 is used.
Return a browsable object (or a list of objects) according to the OSV name and ID (or IDs) supplied. The join parameter allow to get at the same time the first level of relations (Many2One, One2Many and Many2Many). refresh option will reinitialize the object if this one has already been loaded previously.
Create a new record with the specified values contained in the vals dictionary (e.g. {'name': 'John', ...}). Return the ID of the new record.
Download a report from the OpenERP server via XMLRPC and return the path of the file.
WARNING: not sufficiently tested.
XMLRPC Workflow query.
WARNING: not sufficiently tested.
Execute a simple XMLRPC method method on the OSV server class osv_name. *args parameters varies according to the method used.
Return the OSV name of the OSV instance osv_obj supplied.
Log in as the given user with the password passwd on the database database and return the corresponding User browsable object. If database is not specified, the default one will be used instead. If no database is found, a LoginError exception will be raised.
Return the ID of each record with the values of the requested fields fields from the OSV server class osv_name. If fields is not specified, all fields values will be retrieved.
Restore original values of the object osv_obj from data retrieved on the OpenERP server. Thus, all changes made locally on the object are canceled.
Cancel all changes made locally on the object osv_obj. No request to the server is executed to perform this operation. Therefore, values restored may be outdated.
Return a list of IDs of records matching the given criteria in args parameter. args must be of the form [('name', '=', 'John'), (...)]
Delete records with the given IDs (e.g. [1, 42, ...]). osv parameter may be the OSV server class name (e.g. 'sale.order') or an OSV instance (browsable object). In the latter case, the parameter ids is useless. Return True.
Update records with given IDs (e.g. [1, 42, ...]) with the given values contained in the vals dictionary (e.g. {'name': 'John', ...}). osv parameter may be the OSV server class name (e.g. 'sale.order') or an OSV instance (browsable object). In the latter case, vals will automatically contain all the changed values of the object and ids the object ID, thus the parameters ids and vals are useless. Return True.
The table below presents the Python types used for each OpenERP fields:
OpenERP fields | Python types used in OERPLib |
---|---|
fields.binary | ? |
fields.boolean | bool |
fields.char | basestring |
fields.date | datetime.date |
fields.datetime | datetime.datetime |
fields.float | float |
fields.integer | integer |
fields.selection | basestring |
fields.text | basestring |
Exceptions made for relation fields:
OpenERP fields | Types used in OERPLib |
---|---|
fields.many2one | OSV object |
fields.one2many | list of OSV objects |
fields.many2many | list of OSV objects |