Skip to main content

A Hatch plugin for Odoo projects.

Project description

hatch-odoo

PyPI - Version PyPI - Python Version


A hatch(ling) plugin to work with projects containing Odoo addons. This tool will help you package a project containing Odoo addons so it can be installed with pip:

  • automatically generates dependencies based on Odoo addons manifests,
  • package addons into the odoo/addons namespace independently of the source project layout,
  • install the addons in editable mode without fiddling with --addons-path,

Table of Contents

Quick start

Assuming you have a project containing your awesome Odoo addons at the root of your project repository, you can set it up by creating a pyproject.toml file like so.

# Use the hatchling build backend, with the hatch-odoo plugin.
[build-system]
requires = ["hatchling", "hatch-odoo"]
build-backend = "hatchling.build"

[project]
name = "MyAwesomeProject"
version = "1.0"
readme = "README.md"
# Dependencies are dynamic because they will be generated from Odoo addons manifests.
dynamic = ["dependencies"]

# Enable the hatch-odoo metadata hook to generate dependencies from addons manifests.
[tool.hatch.metadata.hooks.odoo-addons-dependencies]
# Enable the hatch-odoo build hook to package the Odoo addons into odoo/addons.
[tool.hatch.build.hooks.odoo-addons-dirs]

[tool.hatch-odoo]
# If our addons have non standard version numbers, let's help hatch-odoo discover the Odoo version.
odoo_version_override = "15.0"
# Let's add additional dependencies that are not declared in addons manifests.
dependencies = ["click-odoo-contrib"]
# Our addons are in the project root directory.
addons_dirs = ["."]

You can then install it together with its dependencies in a virtual environment with a procedure like this:

# python3 -m venv .venv
# .venv/bin/activate
# pip install --upgrade pip setuptools wheel
# pip install -r https://raw.githubusercontent.com/odoo/odoo/15.0/requirements.txt
# pip install -e git+https://github.com/odoo/odoo@15.0
# pip install -e .
# odoo

All dependencies (such as OCA addons and external dependencies) declared in your project addons manifests will be downloaded and installed from PyPI automatically.

There is no need to configure addons path, since the addons are installed in odoo/addons, the regular Python import machinery works out of the box

You can then pin dependencies for reproducibility with pip freeze or other tools. pip-deepfreeze is known to work well with git URLs, but other tools such as pip-tools, may work as well.

Alternative project layouts

Depending on your tastes and requirements, there are several alternative ways to organize your source code. The test projects in tests/data each have a README that describe the layout and corresponding tradeoffs, with the corresponding pyproject.toml.

License

hatch-odoo is distributed under the terms of the MIT license.

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

hatch_odoo-0.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

hatch_odoo-0.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file hatch_odoo-0.1.tar.gz.

File metadata

  • Download URL: hatch_odoo-0.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for hatch_odoo-0.1.tar.gz
Algorithm Hash digest
SHA256 c02e1f495252cc65d8fed6463b0c80919ec7d8d0deb1f81503da56a0ae7aeb39
MD5 d9eb0607032d5dc6bc15f244e5abf398
BLAKE2b-256 5224f1aa0ab28da53bbece35793f8cc67aa22cb7e812a16ff07c00c7db3e4dcc

See more details on using hashes here.

File details

Details for the file hatch_odoo-0.1-py3-none-any.whl.

File metadata

  • Download URL: hatch_odoo-0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for hatch_odoo-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc51d290127c318aeb824984a2b27dded684b054fb9e9657d16d07b4d814fa22
MD5 010417b9d272432eb2a7c017f129e6de
BLAKE2b-256 967767b8841b4d3c7a4a645d59d88f41eef2533848b8f6a012729fdd48428daa

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