Odoo API Wrapper
A wrapper for Odoo's External API.
You can check out the official documentation here.
odoo_api_wrapper.api.Api is the main class, odoo_api_wrapper.api.Operations defines
the operations used for odoo_api_wrapper.api.Api.call, raises
odoo_api_wrapper.api.APIError.
Installation
pip install odoo-api-wrapper
Usage Examples
Instantiate an Api
Create an instance of the API to start using it.
import odoo_api_wrapper
api = odoo_api_wrapper.Api("http://localhost:8069", "db", "1001", "password")
Define your model
partner = odoo_api_wrapper.Model(api, "res.partner")
List records
Records can be listed and filtered via search().
partner.search([[['is_company', '=', True]]])
Count records
Rather than retrieve a possibly gigantic list of records and count them,
search_count() can be used to retrieve only the number of records matching the query.
It takes the same domain filter as search() and no other parameter.
partner.search_count([[['is_company', '=', True]]])
Read records
Record data are accessible via the read() method, which takes a list of ids (as
returned by search()), and optionally a list of fields to fetch. By default, it
fetches all the fields the current user can read, which tends to be a huge amount.
ids = partner.search([[['is_company', '=', True]]], {'limit': 1})
[record] = partner.read([ids])
# count the number of fields fetched by default
len(record)
List record fields
fields_get() can be used to inspect a model’s fields and check which ones seem to be
of interest.
partner.fields_get([], {'attributes': ['string', 'help', 'type']})
Search and read
Because it is a very common task, Odoo provides a search_read() shortcut which, as
its name suggests, is equivalent to a search() followed by a read(), but avoids
having to perform two requests and keep ids around.
partner.search_read(
[[['is_company', '=', True]]],
{'fields': ['name', 'country_id', 'comment'], 'limit': 5},
)
Create records
Records of a model are created using create(). The method creates a single record and
returns its database identifier.
id = partner.create([{'name': "New Partner"}])
Update records
Records can be updated using write(). It takes a list of records to update and a
mapping of updated fields to values similar to create().
partner.write([[id], {'name': "Newer partner"}])
Delete records
Records can be deleted in bulk by providing their ids to unlink().
partner.unlink([[id]])
Metadata
Release files for odoo-api-wrapper 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| odoo_api_wrapper-0.2.3.tar.gz | 5.7 kB | Details |
Release files / odoo_api_wrapper-0.2.3.tar.gz
| Download URL | odoo_api_wrapper-0.2.3.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a474bffd530a7d38bf1cde5cebf31542027a603c7825baddb793393d65c2666
|
|
BLAKE2b-256 checksum How to use checksums |
ee4cab121382f90b8615fce5e379ef33eea6ab4ed9e8b51bb08d3bbe949fa9ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|