odoorpc_toolbox API Reference

Extension toolkit for OdooRPC providing helper utilities, field mappers, and batch record operations.

odoorpc_toolbox.EqOdooConnection
Python Library Documentation: class EqOdooConnection in module odoorpc_toolbox.base_helper

class EqOdooConnection(odoorpc_toolbox.odoo_connection.OdooConnection)
 |  EqOdooConnection(eq_yaml_path: str, cache_maxsize: int = 256, cache_ttl: float = 3600) -> None
 |
 |  Extended Odoo connection class with helper functions.
 |
 |  This class inherits from OdooConnection and adds various helper methods
 |  for common Odoo operations. Static lookups (countries, states, UoMs, titles,
 |  categories) are cached via a TTL cache to reduce RPC calls.
 |
 |  Method resolution order:
 |      EqOdooConnection
 |      odoorpc_toolbox.odoo_connection.OdooConnection
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, eq_yaml_path: str, cache_maxsize: int = 256, cache_ttl: float = 3600) -> None
 |      Initializes the connection and the lookup cache.
 |
 |      Args:
 |          eq_yaml_path: Path to the YAML configuration file.
 |          cache_maxsize: Maximum number of cached lookup entries (default: 256).
 |          cache_ttl: Time-to-live for cache entries in seconds (default: 3600).
 |
 |  check_if_company_exists(self, company_name: str, zip_code: str, city: str) -> int | None
 |      Checks if a company exists in the res_partner table.
 |
 |      Args:
 |          company_name: The name of the company.
 |          zip_code: The zip code of the company.
 |          city: The city of the company.
 |
 |      Returns:
 |          The ID of the company if found, None otherwise.
 |
 |  clear_cache(self) -> None
 |      Clear the lookup cache, forcing fresh RPC calls on next access.
 |
 |  create_partner(self, name: str, is_company: bool = False, email: str | None = None, phone: str | None = None, street: str | None = None, city: str | None = None, zip_code: str | None = None, country_id: int | None = None, **kwargs: Any) -> int
 |      Creates a new partner (contact or company) in Odoo.
 |
 |      Args:
 |          name: The name of the partner.
 |          is_company: Whether this is a company (True) or individual (False).
 |          email: Email address.
 |          phone: Phone number.
 |          street: Street address.
 |          city: City name.
 |          zip_code: ZIP/postal code.
 |          country_id: ID of the country.
 |          **kwargs: Additional fields to set on the partner.
 |
 |      Returns:
 |          The ID of the newly created partner.
 |
 |  execute_method(self, model: str, method: str, record_ids: list[int] | None = None, args: list[typing.Any] | None = None, kwargs: dict[str, typing.Any] | None = None) -> Any
 |      Executes a method on an Odoo model via RPC.
 |
 |      This is a generic method to call any Odoo model method.
 |
 |      Args:
 |          model: The Odoo model name (e.g., 'res.partner').
 |          method: The method name to call (e.g., 'name_search').
 |          record_ids: Optional list of record IDs to call the method on.
 |          args: Optional positional arguments for the method.
 |          kwargs: Optional keyword arguments for the method.
 |
 |      Returns:
 |          The result of the method call.
 |
 |      Raises:
 |          ValueError: If the method name starts with '_' (private/magic methods).
 |
 |  extract_street_address_part(self, street_infos: str) -> tuple[str, str]
 |      Extracts street and house number from a string.
 |
 |      Args:
 |          street_infos: The string containing street and house number.
 |
 |      Returns:
 |          A tuple containing (street, house_number).
 |
 |  get_country_id(self, country_name: str) -> int | None
 |      Returns the country ID for a given country name.
 |
 |      Args:
 |          country_name: The name of the country (e.g., 'Germany', 'Deutschland').
 |
 |      Returns:
 |          The ID of the country if found, None otherwise.
 |
 |  get_country_id_by_code(self, country_code: str) -> int | None
 |      Returns the country ID for a given ISO country code.
 |
 |      Args:
 |          country_code: The ISO 3166-1 alpha-2 country code (e.g., 'DE', 'US').
 |
 |      Returns:
 |          The ID of the country if found, None otherwise.
 |
 |  get_ir_sequence_number_next_actual(self, code: str) -> int | None
 |      Returns the next actual number in the sequence.
 |
 |      Uses a single search_read RPC call instead of separate search + browse.
 |
 |      Args:
 |          code: The code of the sequence.
 |
 |      Returns:
 |          The next actual number in the sequence if found, None otherwise.
 |
 |  get_picture(self, picture_path: str, max_size_mb: int = 50, allowed_directory: str | None = None) -> str | None
 |      Loads a picture from a file path and encodes it in BASE64.
 |
 |      Args:
 |          picture_path: The path to the picture file.
 |          max_size_mb: Maximum allowed file size in megabytes (default: 50).
 |          allowed_directory: If set, only files within this directory are allowed.
 |
 |      Returns:
 |          The BASE64 encoded picture if the file exists, None otherwise.
 |
 |      Raises:
 |          ValueError: If the file exceeds the size limit or is outside the allowed directory.
 |
 |  get_product_by_ref(self, default_code: str) -> int | None
 |      Returns the product ID for a given internal reference (default_code).
 |
 |      Args:
 |          default_code: The internal reference/SKU of the product.
 |
 |      Returns:
 |          The ID of the product if found, None otherwise.
 |
 |  get_product_template_by_ref(self, default_code: str) -> int | None
 |      Returns the product template ID for a given internal reference.
 |
 |      Args:
 |          default_code: The internal reference/SKU of the product.
 |
 |      Returns:
 |          The ID of the product template if found, None otherwise.
 |
 |  get_product_uom_id(self, uom: str) -> int
 |      Returns the ID of the product unit of measure.
 |
 |      Args:
 |          uom: The unit of measure to search for.
 |
 |      Returns:
 |          The ID of the unit of measure if found, 1 (default) otherwise.
 |
 |  get_res_partner_category_id(self, category_name: str) -> int
 |      Gets or creates a partner category (tag).
 |
 |      If the category doesn't exist, it will be created.
 |
 |      Args:
 |          category_name: Name of the category/tag.
 |
 |      Returns:
 |          ID of the existing or newly created category.
 |
 |  get_res_partner_id(self, supplierno: str | None = None, customerno: str | None = None) -> list[int]
 |      Retrieves partner IDs based on supplier or customer numbers.
 |
 |      Args:
 |          supplierno: Optional supplier number to search for.
 |          customerno: Optional customer number to search for.
 |
 |      Returns:
 |          List of matching partner IDs.
 |
 |  get_res_partner_title_id(self, title: str) -> int | None
 |      Returns the ID of the partner title.
 |
 |      Args:
 |          title: The title to search for.
 |
 |      Returns:
 |          The ID of the title if found, None otherwise.
 |
 |  get_state_id(self, country_id: int, state_name: str) -> int | None
 |      Returns the state ID (Bundesland) for a given country and state name.
 |
 |      Args:
 |          country_id: The ID of the country in Odoo.
 |          state_name: The name of the state/province/bundesland.
 |
 |      Returns:
 |          The ID of the state if found, None otherwise.
 |
 |  search_read(self, model: str, domain: list | None = None, fields: list[str] | None = None, limit: int | None = None, offset: int = 0, order: str | None = None) -> list[dict[str, typing.Any]]
 |      Searches for records and returns specified fields in a single RPC call.
 |
 |      Uses the native Odoo ``search_read`` method via ``execute_kw`` which
 |      performs the search and read in one server-side operation instead of
 |      two separate RPC calls.
 |
 |      Args:
 |          model: The Odoo model name (e.g., 'res.partner').
 |          domain: Search domain (e.g., [('is_company', '=', True)]).
 |          fields: List of fields to return (e.g., ['name', 'email']).
 |          limit: Maximum number of records to return.
 |          offset: Number of records to skip.
 |          order: Sort order (e.g., 'name asc').
 |
 |      Returns:
 |          List of dictionaries containing the requested fields.
 |
 |  set_ir_sequence_number_next_actual(self, code: str, set_value: int) -> bool
 |      Sets the next actual number in the sequence.
 |
 |      Uses search + write (2 RPC calls) instead of search + browse + write (3-4 calls).
 |
 |      Args:
 |          code: The code of the sequence.
 |          set_value: The new value for the next actual number.
 |
 |      Returns:
 |          True if the operation was successful, False otherwise.
 |
 |  set_stock_warehouse_orderpoint(self, product_id: int) -> bool
 |      Sets the reorder point for a product.
 |
 |      Args:
 |          product_id: The ID of the product.
 |
 |      Returns:
 |          True if the operation was successful, False otherwise.
 |
 |  string_contains_numbers(self, source: str) -> bool
 |      Checks if a string contains numbers.
 |
 |      Args:
 |          source: The string to check.
 |
 |      Returns:
 |          True if the string contains numbers, False otherwise.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from odoorpc_toolbox.odoo_connection.OdooConnection:
 |
 |  odoo_connect(self) -> odoorpc_toolbox.odoo.ODOO
 |      Establishes connection to the Odoo server.
 |
 |      Returns:
 |          ODOO: Connected Odoo instance.
 |
 |      Raises:
 |          OdooConnectionError: If connection to server fails.
 |          OdooAuthError: If authentication fails.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from odoorpc_toolbox.odoo_connection.OdooConnection:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
odoorpc_toolbox.Error
Python Library Documentation: class Error in module odoorpc_toolbox.exceptions

class Error(builtins.Exception)
 |  Base class for all OdooRPC-level exceptions.
 |
 |  Method resolution order:
 |      Error
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |
 |  Data descriptors defined here:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.Exception:
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.Exception:
 |
 |  __new__(*args, **kwargs) class method of builtins.Exception
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setstate__(...)
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
odoorpc_toolbox.HttpxTransport
Python Library Documentation: class HttpxTransport in module odoorpc_toolbox.rpc.transport

class HttpxTransport(builtins.object)
 |  HttpxTransport(http2: 'bool' = True, retry_config: 'RetryConfig | None' = None, pool_connections: 'int' = 10, pool_maxsize: 'int' = 10, verify: 'bool' = True) -> 'None'
 |
 |  Transport implementation using httpx with connection pooling and HTTP/2.
 |
 |  Requires the ``httpx[http2]`` package. Provides synchronous HTTP client
 |  with configurable retry logic, connection pooling, and optional HTTP/2 support.
 |
 |  Args:
 |      http2: Enable HTTP/2 support (default: True).
 |      retry_config: Retry configuration. None disables retries.
 |      pool_connections: Maximum number of pooled connections (default: 10).
 |      pool_maxsize: Maximum pool size (default: 10).
 |      verify: SSL verification (default: True).
 |
 |  Raises:
 |      ImportError: If httpx is not installed.
 |
 |  Methods defined here:
 |
 |  __init__(self, http2: 'bool' = True, retry_config: 'RetryConfig | None' = None, pool_connections: 'int' = 10, pool_maxsize: 'int' = 10, verify: 'bool' = True) -> 'None'
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  close(self) -> 'None'
 |      Close the httpx client and release connections.
 |
 |  request(self, url: 'str', data: 'bytes | None' = None, headers: 'dict[str, str] | None' = None, timeout: 'float | None' = None) -> 'TransportResponse'
 |      Execute an HTTP request via httpx with optional retry logic.
 |
 |      Args:
 |          url: The full URL to request.
 |          data: Request body as bytes.
 |          headers: HTTP headers dict.
 |          timeout: Request timeout in seconds.
 |
 |      Returns:
 |          TransportResponse with status, body, and headers.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
odoorpc_toolbox.InternalError
Python Library Documentation: class InternalError in module odoorpc_toolbox.exceptions

class InternalError(Error)
 |  Exception raised for errors occurring during an internal operation.
 |
 |  Method resolution order:
 |      InternalError
 |      Error
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |
 |  Data descriptors inherited from Error:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.Exception:
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.Exception:
 |
 |  __new__(*args, **kwargs) class method of builtins.Exception
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setstate__(...)
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
odoorpc_toolbox.MetricsTransport
Python Library Documentation: class MetricsTransport in module odoorpc_toolbox.rpc.metrics

class MetricsTransport(builtins.object)
 |  MetricsTransport(transport: 'Transport', metrics: 'RequestMetrics | None' = None) -> 'None'
 |
 |  Decorator transport that records request metrics.
 |
 |  Wraps any Transport implementation and transparently records
 |  timing and error data for each request.
 |
 |  Args:
 |      transport: The underlying Transport to wrap.
 |      metrics: RequestMetrics instance. If None, creates a new one.
 |
 |  Example:
 |      >>> from odoorpc_toolbox.rpc.transport import UrllibTransport
 |      >>> inner = UrllibTransport()
 |      >>> metrics = RequestMetrics()
 |      >>> transport = MetricsTransport(inner, metrics)
 |      >>> # Use transport.request() as normal; metrics are recorded automatically
 |      >>> metrics.total_requests
 |      0
 |
 |  Methods defined here:
 |
 |  __init__(self, transport: 'Transport', metrics: 'RequestMetrics | None' = None) -> 'None'
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  close(self) -> 'None'
 |      Close the underlying transport.
 |
 |  request(self, url: 'str', data: 'bytes | None' = None, headers: 'dict[str, str] | None' = None, timeout: 'float | None' = None) -> 'TransportResponse'
 |      Execute a request and record metrics.
 |
 |      Args:
 |          url: The full URL to request.
 |          data: Request body as bytes.
 |          headers: HTTP headers dict.
 |          timeout: Request timeout in seconds.
 |
 |      Returns:
 |          TransportResponse from the underlying transport.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  metrics
 |      Return the metrics collector.
 |
 |  opener
 |      Return the underlying transport's opener for backward compatibility.
 |
 |      Raises:
 |          AttributeError: If the underlying transport has no opener.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
odoorpc_toolbox.ODOO
Python Library Documentation: class ODOO in module odoorpc_toolbox.odoo

class ODOO(builtins.object)
 |  ODOO(host: 'str' = 'localhost', protocol: 'str' = 'jsonrpc', port: 'int' = 8069, timeout: 'float' = 120, version: 'str | None' = None, opener=None, transport=None) -> 'None'
 |
 |  Main class for connecting to and interacting with an Odoo server.
 |
 |  Uses JSON-RPC protocol. Supported protocols: 'jsonrpc' and 'jsonrpc+ssl'.
 |
 |  Example:
 |      >>> from odoorpc_toolbox.odoo import ODOO
 |      >>> odoo = ODOO('localhost', protocol='jsonrpc', port=8069)
 |      >>> odoo.login('mydb', 'admin', 'admin')
 |      >>> odoo.env.user.name
 |      'Administrator'
 |
 |  You can also define a custom URL opener for HTTP basic auth:
 |      >>> import urllib.request
 |      >>> pwd_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
 |      >>> pwd_mgr.add_password(None, "http://example.net", "user", "pass")
 |      >>> auth_handler = urllib.request.HTTPBasicAuthHandler(pwd_mgr)
 |      >>> opener = urllib.request.build_opener(auth_handler)
 |      >>> odoo = ODOO('example.net', port=80, opener=opener)
 |
 |  Methods defined here:
 |
 |  __init__(self, host: 'str' = 'localhost', protocol: 'str' = 'jsonrpc', port: 'int' = 8069, timeout: 'float' = 120, version: 'str | None' = None, opener=None, transport=None) -> 'None'
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  close(self) -> 'bool'
 |      Same as logout. For compatibility with contextlib.closing.
 |
 |  execute(self, model: 'str', method: 'str', *args) -> 'Any'
 |      Execute a method of a model.
 |
 |      For Odoo >= 19, uses the JSON-2 API endpoint /json/2/<model>/<method>.
 |      For older versions, uses the legacy /jsonrpc service dispatch.
 |
 |      Args:
 |          model: The Odoo model name.
 |          method: The method name.
 |          *args: Positional arguments for the method.
 |
 |      Returns:
 |          The result of the method call.
 |
 |  execute_kw(self, model: 'str', method: 'str', args: 'list | None' = None, kwargs: 'dict | None' = None) -> 'Any'
 |      Execute a method of a model with keyword arguments.
 |
 |      For Odoo >= 19, uses the JSON-2 API endpoint /json/2/<model>/<method>.
 |      For older versions, uses the legacy /jsonrpc service dispatch.
 |
 |      Args:
 |          model: The Odoo model name.
 |          method: The method name.
 |          args: Positional arguments list.
 |          kwargs: Keyword arguments dictionary.
 |
 |      Returns:
 |          The result of the method call.
 |
 |  http(self, url: 'str', data: 'str | None' = None, headers: 'dict | None' = None)
 |      Execute a raw HTTP query.
 |
 |      Args:
 |          url: The endpoint URL.
 |          data: POST data string.
 |          headers: HTTP headers dictionary.
 |
 |      Returns:
 |          HTTP response object.
 |
 |  json(self, url: 'str', params: 'dict') -> 'dict'
 |      Execute a low-level JSON-RPC query.
 |
 |      Args:
 |          url: The endpoint URL.
 |          params: Dictionary of parameters.
 |
 |      Returns:
 |          The JSON response as a dictionary.
 |
 |      Raises:
 |          RPCError: If the response contains an error.
 |
 |  login(self, db: 'str', login: 'str' = 'admin', password: 'str' = 'admin', api_key: 'str | None' = None) -> 'None'
 |      Log in to the Odoo server.
 |
 |      For Odoo >= 19, uses the JSON-2 API with Bearer token auth: the API
 |      key (or the password field, which doubles as API key for backward
 |      compatibility) is the complete credential - there is no login
 |      round-trip. The user context and uid are bootstrapped via
 |      res.users/context_get (the current user is derived server-side from
 |      the API key). When no explicit ``api_key`` is given and the server
 |      rejects the password as Bearer token (real passwords are not valid
 |      API keys), login falls back to the deprecated /jsonrpc dispatch.
 |      For Odoo 10-18, uses the legacy /jsonrpc service dispatch; an
 |      explicit ``api_key`` is used as password substitute (valid since
 |      Odoo 14). For Odoo < 10, uses /web/session/authenticate.
 |
 |      Args:
 |          db: Database name.
 |          login: Username (default: 'admin').
 |          password: Password (default: 'admin'). On Odoo >= 19 this value
 |              is tried as API key when ``api_key`` is not given.
 |          api_key: Odoo API key for Bearer auth (Odoo >= 19). Takes
 |              precedence over ``password`` for the JSON-2 API.
 |
 |      Raises:
 |          RPCError: If login fails.
 |
 |  logout(self) -> 'bool'
 |      Log out the user.
 |
 |      Returns:
 |          True if successful, False if no user was logged in.
 |
 |  save(self, name: 'str', rc_file: 'str' = '~/.odoorpcrc') -> 'None'
 |      Save the current session to an RC file.
 |
 |      Args:
 |          name: Session identifier.
 |          rc_file: Path to the RC file (default: ~/.odoorpcrc).
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  list(rc_file: 'str' = '~/.odoorpcrc') -> 'list[str]'
 |      Return a list of all stored session names.
 |
 |      Args:
 |          rc_file: Path to the RC file (default: ~/.odoorpcrc).
 |
 |      Returns:
 |          List of session names.
 |
 |  load(name: 'str', rc_file: 'str' = '~/.odoorpcrc') -> 'ODOO'
 |      Load and return a connected ODOO session.
 |
 |      Args:
 |          name: Session identifier.
 |          rc_file: Path to the RC file (default: ~/.odoorpcrc).
 |
 |      Returns:
 |          A connected ODOO instance.
 |
 |  remove(name: 'str', rc_file: 'str' = '~/.odoorpcrc') -> 'bool'
 |      Remove a stored session.
 |
 |      Args:
 |          name: Session identifier.
 |          rc_file: Path to the RC file (default: ~/.odoorpcrc).
 |
 |      Returns:
 |          True if removed.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  config
 |      Dictionary of available configuration options.
 |
 |      Options:
 |          - auto_commit: Auto-commit record changes (default: True)
 |          - auto_context: Send user context with model calls (default: True)
 |          - timeout: RPC request timeout in seconds (default: 120)
 |
 |  db
 |      The database management service.
 |
 |  env
 |      The environment wrapping data to manage records.
 |
 |      Example:
 |          >>> Partner = odoo.env['res.partner']
 |
 |  host
 |      Hostname or IP address of the server.
 |
 |  metrics
 |      Return RequestMetrics if a MetricsTransport is in use, else None.
 |
 |  port
 |      The port used.
 |
 |  protocol
 |      The protocol used.
 |
 |  report
 |      The report management service.
 |
 |  version
 |      The version of the server.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
odoorpc_toolbox.OdooAuthError
Python Library Documentation: class OdooAuthError in module odoorpc_toolbox.exceptions

class OdooAuthError(OdooConnectionError)
 |  Exception raised for authentication errors.
 |
 |  Method resolution order:
 |      OdooAuthError
 |      OdooConnectionError
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |
 |  Data descriptors inherited from OdooConnectionError:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.Exception:
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.Exception:
 |
 |  __new__(*args, **kwargs) class method of builtins.Exception
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setstate__(...)
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
odoorpc_toolbox.OdooConfigError
Python Library Documentation: class OdooConfigError in module odoorpc_toolbox.exceptions

class OdooConfigError(OdooConnectionError)
 |  Exception raised for configuration file errors.
 |
 |  Method resolution order:
 |      OdooConfigError
 |      OdooConnectionError
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |
 |  Data descriptors inherited from OdooConnectionError:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.Exception:
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.Exception:
 |
 |  __new__(*args, **kwargs) class method of builtins.Exception
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setstate__(...)
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
odoorpc_toolbox.OdooConnection
Python Library Documentation: class OdooConnection in module odoorpc_toolbox.odoo_connection

class OdooConnection(builtins.object)
 |  OdooConnection(eq_yaml_path: str) -> None
 |
 |  Base class for establishing and managing Odoo server connections.
 |
 |  Attributes:
 |      odoo_address: Server URL address.
 |      odoo_port: Server port number.
 |      user: Username for authentication.
 |      pw: Password for authentication.
 |      api_key: Odoo API key for Bearer auth (Odoo 19+). Takes precedence
 |          over the password for the JSON-2 API when set.
 |      db: Database name.
 |      protocol: Connection protocol (jsonrpc or jsonrpc+ssl).
 |      odoo_version: Odoo server version.
 |      odoo: ODOO connection instance.
 |      transport_config: Parsed transport configuration dict.
 |      retry_config: Parsed retry configuration dict.
 |      timeout_config: Parsed timeout configuration dict.
 |      cache_config: Parsed cache configuration dict.
 |
 |  Methods defined here:
 |
 |  __init__(self, eq_yaml_path: str) -> None
 |      Initializes the connection using configuration from a YAML file.
 |
 |      Args:
 |          eq_yaml_path: Path to the YAML configuration file.
 |
 |      Raises:
 |          OdooConfigError: If the YAML configuration file is not found or malformed.
 |          OdooConnectionError: If the connection to the server fails.
 |
 |  odoo_connect(self) -> odoorpc_toolbox.odoo.ODOO
 |      Establishes connection to the Odoo server.
 |
 |      Returns:
 |          ODOO: Connected Odoo instance.
 |
 |      Raises:
 |          OdooConnectionError: If connection to server fails.
 |          OdooAuthError: If authentication fails.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
odoorpc_toolbox.OdooConnectionError
Python Library Documentation: class OdooConnectionError in module odoorpc_toolbox.exceptions

class OdooConnectionError(builtins.Exception)
 |  Base exception for Odoo connection errors.
 |
 |  Method resolution order:
 |      OdooConnectionError
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |
 |  Data descriptors defined here:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.Exception:
 |
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.Exception:
 |
 |  __new__(*args, **kwargs) class method of builtins.Exception
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __repr__(self, /)
 |      Return repr(self).
 |
 |  __setstate__(...)
 |
 |  __str__(self, /)
 |      Return str(self).
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
odoorpc_toolbox.RPCError
Python Library Documentation: class RPCError in module odoorpc_toolbox.exceptions

class RPCError(Error)
 |  RPCError(message: str, info: dict | bool = False) -> None
 |
 |  Exception raised for errors related to RPC queries.
 |
 |  Error details (like the Odoo server traceback) are available
 |  through the `info` attribute.
 |
 |  Example:
 |      >>> try:
 |      ...     odoo.execute('res.users', 'wrong_method')
 |      ... except RPCError as exc:
 |      ...     print(exc.info)
 |
 |  Method resolution order:
 |      RPCError
 |      Error
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__(self, message: str, info: dict | bool = False) -> None
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __repr__(self) -> str
 |      Return repr(self).
 |
 |  __str__(self) -> str
 |      Return str(self).
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from Error:
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.Exception:
 |
 |  __new__(*args, **kwargs) class method of builtins.Exception
 |      Create and return a new object.  See help(type) for accurate signature.
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __reduce__(...)
 |      Helper for pickle.
 |
 |  __setstate__(...)
 |
 |  add_note(...)
 |      Exception.add_note(note) --
 |      add a note to the exception
 |
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |
 |  __cause__
 |      exception cause
 |
 |  __context__
 |      exception context
 |
 |  __dict__
 |
 |  __suppress_context__
 |
 |  __traceback__
 |
 |  args
odoorpc_toolbox.RequestMetrics
Python Library Documentation: class RequestMetrics in module odoorpc_toolbox.rpc.metrics

class RequestMetrics(builtins.object)
 |  RequestMetrics(total_requests: 'int' = 0, total_errors: 'int' = 0, total_time_ms: 'float' = 0.0, _lock: 'threading.Lock' = <factory>) -> None
 |
 |  Thread-safe request metrics collector.
 |
 |  Tracks total requests, errors, and cumulative response time.
 |
 |  Attributes:
 |      total_requests: Number of completed requests.
 |      total_errors: Number of failed requests.
 |      total_time_ms: Cumulative response time in milliseconds.
 |
 |  Example:
 |      >>> metrics = RequestMetrics()
 |      >>> metrics.record(time_ms=45.2)
 |      >>> metrics.record(time_ms=120.5, error=True)
 |      >>> metrics.total_requests
 |      2
 |      >>> metrics.avg_time_ms
 |      82.85
 |
 |  Methods defined here:
 |
 |  __eq__(self, other)
 |      Return self==value.
 |
 |  __init__(self, total_requests: 'int' = 0, total_errors: 'int' = 0, total_time_ms: 'float' = 0.0, _lock: 'threading.Lock' = <factory>) -> None
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __repr__(self)
 |      Return repr(self).
 |
 |  record(self, time_ms: 'float', error: 'bool' = False) -> 'None'
 |      Record a completed request.
 |
 |      Args:
 |          time_ms: Response time in milliseconds.
 |          error: Whether the request resulted in an error.
 |
 |  reset(self) -> 'None'
 |      Reset all metrics to zero.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  avg_time_ms
 |      Average response time in milliseconds. Returns 0.0 if no requests recorded.
 |
 |  error_rate
 |      Error rate as a fraction (0.0 to 1.0). Returns 0.0 if no requests recorded.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __annotations__ = {'_lock': 'threading.Lock', 'total_errors': 'int', '...
 |
 |  __dataclass_fields__ = {'_lock': Field(name='_lock',type='threading.Lo...
 |
 |  __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,or...
 |
 |  __hash__ = None
 |
 |  __match_args__ = ('total_requests', 'total_errors', 'total_time_ms', '...
 |
 |  total_errors = 0
 |
 |  total_requests = 0
 |
 |  total_time_ms = 0.0
odoorpc_toolbox.RetryConfig
Python Library Documentation: class RetryConfig in module odoorpc_toolbox.rpc.transport

class RetryConfig(builtins.object)
 |  RetryConfig(max_attempts: 'int' = 3, backoff_factor: 'float' = 0.5, retry_on: 'tuple[int, ...]' = (502, 503, 504)) -> None
 |
 |  Configuration for request retry behavior.
 |
 |  Attributes:
 |      max_attempts: Maximum number of request attempts (default: 3).
 |      backoff_factor: Base factor for exponential backoff in seconds (default: 0.5).
 |      retry_on: HTTP status codes that trigger a retry (default: 502, 503, 504).
 |
 |  Methods defined here:
 |
 |  __eq__(self, other)
 |      Return self==value.
 |
 |  __init__(self, max_attempts: 'int' = 3, backoff_factor: 'float' = 0.5, retry_on: 'tuple[int, ...]' = (502, 503, 504)) -> None
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __repr__(self)
 |      Return repr(self).
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __annotations__ = {'backoff_factor': 'float', 'max_attempts': 'int', '...
 |
 |  __dataclass_fields__ = {'backoff_factor': Field(name='backoff_factor',...
 |
 |  __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,or...
 |
 |  __hash__ = None
 |
 |  __match_args__ = ('max_attempts', 'backoff_factor', 'retry_on')
 |
 |  backoff_factor = 0.5
 |
 |  max_attempts = 3
 |
 |  retry_on = (502, 503, 504)
odoorpc_toolbox.TTLCache
Python Library Documentation: class TTLCache in module odoorpc_toolbox.cache

class TTLCache(builtins.object)
 |  TTLCache(maxsize: 'int' = 256, ttl: 'float' = 3600) -> 'None'
 |
 |  Thread-safe cache with time-to-live eviction and max size limit.
 |
 |  Entries expire after ``ttl`` seconds and are lazily evicted on access.
 |  When ``maxsize`` is reached, the oldest entry is removed.
 |
 |  Args:
 |      maxsize: Maximum number of entries (default: 256).
 |      ttl: Time-to-live in seconds (default: 3600).
 |
 |  Example:
 |      >>> cache = TTLCache(maxsize=100, ttl=600)
 |      >>> cache.set("key", "value")
 |      >>> cache.get("key")
 |      'value'
 |
 |  Methods defined here:
 |
 |  __contains__(self, key: 'str') -> 'bool'
 |      Check if a non-expired entry exists for key.
 |
 |  __init__(self, maxsize: 'int' = 256, ttl: 'float' = 3600) -> 'None'
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  __len__(self) -> 'int'
 |      Return number of entries (including potentially expired ones).
 |
 |  clear(self) -> 'None'
 |      Remove all entries from the cache.
 |
 |  get(self, key: 'str') -> 'Any | None'
 |      Retrieve a value by key, returning None if missing or expired.
 |
 |      Args:
 |          key: The cache key.
 |
 |      Returns:
 |          The cached value or None if not found/expired.
 |
 |  set(self, key: 'str', value: 'Any') -> 'None'
 |      Store a value with the current timestamp.
 |
 |      If maxsize is exceeded, the oldest entry is evicted.
 |
 |      Args:
 |          key: The cache key.
 |          value: The value to cache.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  maxsize
 |      Maximum number of cache entries.
 |
 |  ttl
 |      Time-to-live in seconds.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
odoorpc_toolbox.Transport
Python Library Documentation: class Transport in module odoorpc_toolbox.rpc.transport

class Transport(typing.Protocol)
 |  Transport(*args, **kwargs)
 |
 |  Protocol defining the transport interface for RPC communication.
 |
 |  Method resolution order:
 |      Transport
 |      typing.Protocol
 |      typing.Generic
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
 |
 |  close(self) -> 'None'
 |
 |  request(self, url: 'str', data: 'bytes | None' = None, headers: 'dict[str, str] | None' = None, timeout: 'float | None' = None) -> 'TransportResponse'
 |
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |
 |  __subclasshook__ = _proto_hook(other) from typing
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __abstractmethods__ = frozenset()
 |
 |  __annotations__ = {}
 |
 |  __non_callable_proto_members__ = set()
 |
 |  __parameters__ = ()
 |
 |  __protocol_attrs__ = {'close', 'request'}
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from typing.Protocol:
 |
 |  __init_subclass__(*args, **kwargs)
 |      Function to initialize subclasses.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from typing.Generic:
 |
 |  __class_getitem__(...)
 |      Parameterizes a generic class.
 |
 |      At least, parameterizing a generic class is the *main* thing this
 |      method does. For example, for some generic class `Foo`, this is called
 |      when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
 |
 |      However, note that this method is also called when defining generic
 |      classes in the first place with `class Foo[T]: ...`.
odoorpc_toolbox.UrllibTransport
Python Library Documentation: class UrllibTransport in module odoorpc_toolbox.rpc.transport

class UrllibTransport(builtins.object)
 |  UrllibTransport(opener=None, cookie_jar: 'CookieJar | None' = None) -> 'None'
 |
 |  Transport implementation wrapping the standard urllib opener.
 |
 |  Uses urllib.request with CookieJar for session management.
 |  This is the default transport and requires no extra dependencies.
 |
 |  Args:
 |      opener: Pre-configured urllib opener. If None, creates one with CookieJar.
 |      cookie_jar: CookieJar instance for cookie handling. Ignored if opener is given.
 |
 |  Methods defined here:
 |
 |  __init__(self, opener=None, cookie_jar: 'CookieJar | None' = None) -> 'None'
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  close(self) -> 'None'
 |      Close the transport. No-op for urllib (no persistent connections).
 |
 |  request(self, url: 'str', data: 'bytes | None' = None, headers: 'dict[str, str] | None' = None, timeout: 'float | None' = None) -> 'TransportResponse'
 |      Execute an HTTP request via urllib.
 |
 |      Args:
 |          url: The full URL to request.
 |          data: Request body as bytes.
 |          headers: HTTP headers dict.
 |          timeout: Request timeout in seconds.
 |
 |      Returns:
 |          TransportResponse with status, body, and headers.
 |          HTTP error statuses (4xx/5xx) are returned as responses, not
 |          raised, matching the HttpxTransport behavior so callers can map
 |          status codes to exceptions themselves.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  opener
 |      Return the underlying urllib opener for backward compatibility.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables
 |
 |  __weakref__
 |      list of weak references to the object
odoorpc_toolbox.batch_write
Python Library Documentation: function batch_write in module odoorpc_toolbox.batch

batch_write(odoo: 'ODOO') -> 'Generator[None, None, None]'
    Context manager that batches record writes into fewer RPC calls.

    Temporarily sets ``auto_commit=False`` on the ODOO instance, so field
    assignments are collected locally. On successful exit the dirty records
    are committed in bulk. On exception the local changes are invalidated
    (rolled back).

    Args:
        odoo: A connected ODOO instance.

    Example:
        >>> with batch_write(connection.odoo):
        ...     record.name = "New Name"
        ...     record.email = "new@example.com"
        ...     record.phone = "+49..."
        ... # -> One write() call instead of 3

    Raises:
        Exception: Re-raises any exception after rolling back changes.
odoorpc_toolbox.create_transport
Python Library Documentation: function create_transport in module odoorpc_toolbox.rpc.transport

create_transport(backend: 'str' = 'auto', opener=None, cookie_jar: 'CookieJar | None' = None, **kwargs) -> 'Transport'
    Factory function to create a Transport instance.

    Args:
        backend: Transport backend - 'auto', 'urllib', or 'httpx'.
            'auto' tries httpx first, falls back to urllib.
        opener: Pre-configured urllib opener (only for urllib backend).
        cookie_jar: CookieJar for urllib backend.
        **kwargs: Additional arguments passed to the transport constructor.
            For httpx: http2, retry_config, pool_connections, pool_maxsize, verify.

    Returns:
        A Transport instance.

    Raises:
        ValueError: If backend is not recognized.
        ImportError: If httpx backend is requested but not installed.
odoorpc_toolbox.generate_config
Python Library Documentation: function generate_config in module odoorpc_toolbox.config_generator

generate_config(output_path: 'str | Path' = 'odoo_config.yaml', *, url: 'str' = 'https://odoo.example.com', port: 'int' = 443, user: 'str' = 'admin', password: 'str' = 'admin', api_key: 'str | None' = None, database: 'str' = 'mydb', protocol: 'str' = 'jsonrpc', minimal: 'bool' = False, overwrite: 'bool' = False) -> 'Path'
    Generate a YAML configuration file for odoorpc-toolbox.

    Args:
        output_path: Path for the generated config file.
        url: Odoo server URL.
        port: Odoo server port.
        user: Username for authentication.
        password: Password for authentication.
        api_key: Odoo API key for Bearer auth (Odoo 19+). When omitted, a
            commented hint line is rendered instead.
        database: Database name.
        protocol: RPC protocol (jsonrpc or jsonrpc+ssl).
        minimal: If True, generate only the Server section.
        overwrite: If True, overwrite existing files.

    Returns:
        Path to the generated configuration file.

    Raises:
        FileExistsError: If file exists and overwrite is False.
odoorpc_toolbox.get_available_methods
Python Library Documentation: function get_available_methods in module odoorpc_toolbox.introspection

get_available_methods(cls: type = None, include_inherited: bool = False) -> dict[str, typing.Any]
    Get all available methods with MCP-compatible schema.

    This function returns a complete schema of all available methods
    in the EqOdooConnection class, suitable for MCP server integration.

    Args:
        cls: Class to inspect (defaults to EqOdooConnection).
        include_inherited: Whether to include methods from parent classes.

    Returns:
        MCP-compatible schema with all available methods.
odoorpc_toolbox.get_method_schema
Python Library Documentation: function get_method_schema in module odoorpc_toolbox.introspection

get_method_schema(method_name: str, cls: type = None) -> dict[str, typing.Any] | None
    Get MCP-compatible JSON Schema for a specific method.

    Args:
        method_name: Name of the method to get schema for.
        cls: Class to inspect (defaults to EqOdooConnection).

    Returns:
        MCP-compatible method schema or None if method not found.
odoorpc_toolbox.print_available_methods
Python Library Documentation: function print_available_methods in module odoorpc_toolbox.introspection

print_available_methods(cls: type = None, format: str = 'text') -> None
    Print available methods in human-readable or JSON format.

    Args:
        cls: Class to inspect (defaults to EqOdooConnection).
        format: Output format ('text' or 'json').