Skip to main content

A tool to interact with Odoo's external API.

Project description

otools-rpc

Version LastCommit Status License Downloads

otools-rpc is a Python package for interacting with the Odoo ERP system through XML-RPC requests. It provides a convenient way to communicate with Odoo and perform various operations. Please note that the package is currently in the testing/alpha phase, and further improvements and updates are expected.

Features

The Environment class represents the environment for interacting with the Odoo ERP system. It provides the following features:

  • Authentication: Authenticate with the Odoo system using username and password.
  • Access Models: Access different models (tables) in the Odoo system.
  • Caching: Caching mechanism to improve performance.
  • Logging: Logging capabilities with customizable log levels.

Installation

You can install otools-rpc using pip:

$ pip install otools-rpc

See on pypi: https://pypi.org/project/otools-rpc/

Usage

Environment

Here are some examples of how to use otools-rpc to interact with the Odoo ERP system via the external API:

from otools_rpc.external_api import Environment


url = "http://localhost:8069/"
username = "admin"
password = "admin"
db = "my_odoo"

# Create an instance of the environment
env = Environment(url, username, password, db=db)
env = env.with_context(lang='en_US')
print(env)

# Example: Create an invoice for a specific partner
partner_id = env['res.partner'].search([('name', '=', 'Mitchell Admin')], limit=1)
invoice_vals = {
    'partner_id': partner_id.id,
    'date_invoice': '2023-05-12',
    'type': 'out_invoice',
    'invoice_line_ids': [
        (0, 0, {
            'product_id': env['product.product'].search([('name', '=', 'Product A')], limit=1).id,
            'quantity': 5,
            'price_unit': 10.0,
        }),
        (0, 0, {
            'product_id': env['product.product'].search([('name', '=', 'Product B')], limit=1).id,
            'quantity': 3,
            'price_unit': 15.0,
        }),
    ],
}
invoice_id = env['account.move'].create(invoice_vals)
print("Created invoice:", invoice_id)

# Posting the invoice
invoice_id.action_post()

DBManager

from otools_rpc.db_manager import DBManager

url = "http://localhost:8069/"
master_password = "adminadmin"

dbmanager = DBManager(url, master_password)

#Return list of all the available DB in your Odoo ENV
dbmanager.dbobject.list()

#Duplicating my_odoo to my_new_odoo
dbmanager.duplicate(db='my_odoo', new_name="my_new_odoo")

#Deleting my_new_odoo
dbmanager.drop(db='my_new_odoo')

More details are coming soon...

Stars Watchers Forks

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

otools_rpc-0.5.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file otools_rpc-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: otools_rpc-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for otools_rpc-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2b892a0a1e4451121e9e54ab779f76a201e689cbd3e525f9662cc89978de2d35
MD5 c0547aaaee0df60c92d4ab0a045b5cf1
BLAKE2b-256 5036e5470d4223ccafe9aea568d73e5401acd463055ead5d5b8ec0373770a0fa

See more details on using hashes here.

Supported by

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