Odoo XMLRPC Helper Functions
A small set of wrapper functions for facilitating CRUD operations in Odoo via XMLRPC.
Getting Started
Installing via pip
pip install odoo_rpc_helper
A Simple Connection
from odoo_rpc_helper import OdooRPCHelper
DB = "test" # Set this to your database name
USERNAME = "admin" # Set this to a real username on the DB
PASSWORD = "admin" # Set this to the password for user above
URL = "http://localhost:8069" # Set this to the server URL
odoo = OdooRPCHelper(DB, USERNAME, PASSWORD, URL)
partner_id = odoo.create("res.partner", {"name": "Test Partner"})[0]
odoo.write("res.partner", [partner_id], {"phone": "+1 (123) 456-7890"})
partner = odoo.search_read(
"res.partner",
[['id', '=', partner_id]],
['name', 'phone']
)[0]
print(f"We have a partner with ID {partner['id']} named {partner['name']} "
f" with phone {partner['phone']}")
odoo.unlink("res.partner", [partner_id])
OdooRPCHelper Class
A class to help with various CRUD operations on an Odoo database via XMLRPC.
Methods
init
__init__(self, database: str, username: str, password: str, url: str = 'http://localhost:8069')
Initialize the helper and authenticate with the Odoo server.
- Parameters:
database: The name of the Odoo database to accessusername: The username of the user to execute XMLRPC requests aspassword: The password of the user to execute XMLRPC requests asurl: The URL of the Odoo server
execute_kw
execute_kw(self)
Wrapper around self.models.execute_kw, to save effort on rewriting arguments. Simply omit the database, uid, and password arguments as they will be populated from instance variables.
create
create(self, model: str, fields: Dict)
Wrapper for execute_kw create. Create a single record.
- Parameters:
model: The model of which to create a record.fields: The fields to assign during creation.
- Return: The ID of the created record.
create_multi
create_multi(self, model: str, fields_list: List[Dict])
Wrapper for execute_kw create. Create one or more records. Exactly like calling model.create with a list of dicts in Odoo.
- Parameters:
model: The model of which to create a record.fields_list: The list of dictionaries of fields to assign.
- Return: The ID(s) of the created record(s).
search
search(self, model: str, domain: List)
Wrapper for execute_kw search on a model.
- Parameters:
model: The Odoo model to search.domain: The regular Odoo-style domain. This function wraps it for the XMLRPC call.
- Return: The list of record IDs found in the search.
search_read
search_read(self, model: str, domain: List, fields: List[str] = None)
Wrapper for execute_kw search_read on a model.
- Parameters:
model: The Odoo model to search.domain: The regular Odoo-style domain.fields: The fields to be loaded. All fields loaded by default.
- Return: A list of dictionaries containing the loaded record fields.
read
read(self, model: str, res_ids: List[int], fields: List[str])
Wrapper for calling read on a model.
- Parameters:
model: The Odoo model to browse.res_ids: The IDs of the records to browse.fields: The fields to be read.
- Return: List of dictionaries with the requested fields.
write
write(self, model: str, res_ids: List[int], fields: Dict)
Wrapper for calling write on a model.
- Parameters:
model: Model to write to.res_ids: Record IDs to write to.fields: Fields to write.
unlink
unlink(self, model: str, res_ids: List[int])
Wrapper for calling unlink on a model.
- Parameters:
model: Model to call unlink on.res_ids: Record IDs to unlink.
Metadata
Release files for odoo-rpc-helper 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| odoo_rpc_helper-0.0.7.tar.gz | 4.8 kB | Without provenance | Details for odoo_rpc_helper-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| odoo_rpc_helper-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for odoo_rpc_helper-0.0.7-py3-none-any.whl |
Total release size: 10.5 kB
Release files / odoo_rpc_helper-0.0.7.tar.gz
| Download URL | odoo_rpc_helper-0.0.7.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
847f0e6fec7a256c594d222828ba882920e7c170d7e0430b0254eabd01cef8a7
|
|
BLAKE2b-256 checksum How to use checksums |
464ea93d786c844bedb43f1a620e8a3595d158d0320475a55e881c72a8e92d34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.9
|
Release files / odoo_rpc_helper-0.0.7-py3-none-any.whl
| Download URL | odoo_rpc_helper-0.0.7-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb782293a05ec9c45664c436a6e402aacb2b3ca560a36efb38f68fec612e7912
|
|
BLAKE2b-256 checksum How to use checksums |
9ea9fe7b5ffe5a7d6977544efdfc6055f44eb0c9a63c1d07c55255df1082eb6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.9
|
Security for odoo-rpc-helper 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.