Skip to main content

Library to improve interaction and communication with odoo for integration with other technologies.

Project description

odoo-models-connect

Odoo-Models-Connect is an library to improve interaction and communication with Odoo XML-RPC External API for integration with other technologies.

Installing

Install and update using pip:

$ pip install odoo-models-connect

Example

Initialize the odoo connection:

from odoo_models_connect import ConnectOdoo

odoo = ConnectOdoo('http://localhost:8069', 'db_name')

User authentication in the odoo system:

uid = odoo.authenticate('user_email@mail.com', 'user_password')

In the case of wanting to make queries with the authenticated user in session it is necessary to use the reconnect method and pass a dictionary with the values of email, password and user id:

session = {
    "username": 'user_email@mail.com',
    "password": 'user_password',
    "uid": 7,
}

odoo.reconnect(session)

Making queries

To make a simple search of all the elements of a model is used:

users = odoo.search_read('res.users')

You can place conditions or the fields you want to bring from each element:

users = odoo.search_read('res.users', condition=[['name', '=', 'Admin']], fields=['name', 'login', 'image_1920'])

The read() method works to do a search for elements with a list of element ids:

users = odoo.read('res.users', object_ids=[1, 7, 17])

You can also bring only the fields that are needed:

users = odoo.read('res.users', object_ids=[8, 25], fields=['name', 'login'])

NOTE: ids must be of type integer

You can fetch the id of all the elements of a model stored in a database:

users_ids = odoo.search_ids('res.users')

You can add a condition or domain:

users_ids = odoo.search_ids('res.users', domain=[
[('name', 'ilike', 'John%')]])

The create() method is used to create an element of a model in a database.

data = {
    "name": 'John',
    "login": 'John@mail.com',
    "password": 'john123'
}

odoo.create('res.users', data)

The update() method is used to update an element of a model in a database.

data = {
    "name": 'Juan',
    "login": 'Juan@mail.com',
    "password": 'Juan123'
}

user_id = 9

odoo.update('res.users', user_id, data)

The delete() method is used to delete an element of a model in a database.

user_id = 9

odoo.delete('res.users', user_id)

Project details


Download files

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

Source Distribution

odoo_models_connect-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odoo_models_connect-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file odoo_models_connect-0.1.1.tar.gz.

File metadata

  • Download URL: odoo_models_connect-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for odoo_models_connect-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8bc35e134b17ad37fb7dd1f87f2c194ab4cfb65ef9b40ae4f1f4bd79bc99c9fa
MD5 328b0de5cbbaae33d9168acf51ee27bb
BLAKE2b-256 e104a5991cfe520f85f866dabbf468f3d22bc6660ec06b9c923e7017636c8060

See more details on using hashes here.

File details

Details for the file odoo_models_connect-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_models_connect-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 795735173db9d86443b2acc02f4c8e15fac5c33bf5a504ce36c51a7e9e93dec3
MD5 d4ad767b8746b30de28ad7cd5192be29
BLAKE2b-256 6bc920853b34c5d1a3596471997733166f908d2b466c9ebeece0bbec2ec0b8fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page