Skip to content

Instantly share code, notes, and snippets.

@kaipm
Last active February 18, 2021 09:34
Show Gist options
  • Save kaipm/3c7e4006c77a8ec25d6c39eceb3150b0 to your computer and use it in GitHub Desktop.
Save kaipm/3c7e4006c77a8ec25d6c39eceb3150b0 to your computer and use it in GitHub Desktop.

Odoo with PyPI

  1. Setup postgres 10+
  2. Setup Python 3.6+ venv virtualenv /path/envdir
  3. Install Odoo from source
  4. Open in PyCharm and pick venv, then in Odoo root run pip install -e .
  5. Run pip install odoo-autodiscovery
  6. Create/install addons
  7. Start Odoo with server.conf

Installing addons

From package index

Example:

pip install odoo13-addon-my-addon

From local source

Installing from source allows the addon to be changed even after installing.

Change to the addon folder, where the setup.py file resides, and run the command

pip install -e .

Note: Dependencies are only resolved for published modules. Dependencies for source modules need to be manually installed in the correct order.

From local package

Assuming, you copied the distributable packages to /home/user/Documents/python-packages the command would be:

pip install --no-index --find-links file:///home/user/Documents/python-packages odoo13-addon-my-addon

Dependencies between modules will be resolved.

Creating addons

Overall folder structure

Example:

addons-own
- my_addon
- setup
  - my_addon
    - odoo
      - addons
        - my_addon (sym-link into addons-own/my_addon)
    - setup.py 

This should be similar to how OCA sets up their environment.

Odoo 11 and above

Source: setuptools-odoo

Required folder structure:

odoo
- addons
  - <addon_name>
    - __manifest__.py
    - ...
setup.py

Contents of setup.py:

import setuptools

setuptools.setup(
    setup_requires=['setuptools-odoo'],
    odoo_addon=True,
)

Without additional attributes, this creates packages with the name odoo<version>-addon-<addon_name>. For example odoo13-addon-my-addon.

To create distributable packages, run the following command from within the package directory:

python setup.py sdist bdist_wheel

This creates a dist folder containing the packages. Version will be the same as specified in the Odoo manifest.

Versioning (Odoo 13, 14)

Default scheme: +1.devN

  • Use exact manifest version, if the last commit changed the version
  • Use manifest +1.devN if there are commits that do not change version, N is the number of commits since last version change

Example history for an Odoo module:

Manifest version 13.0.0.0.1 (last commit set this version)
Publish version: 13.0.0.0.1

Manifest version 13.0.0.0.1 (4 commits changing code only)
Publish version: 13.0.0.0.2.dev4

Manifest version 13.0.0.0.2 (last commit set this version, signifies a release)
Publish version: 13.0.0.0.2

Manifest version 13.0.0.0.2 (1 commits changing code only)
Publish version: 13.0.0.0.3.dev1

PyCharm

Exclude sources

In the project view, right click the desired folder, select Mark Directory as and Excluded.

Excluded folders are stored in an .iml file, e.g. .idea/online_o13.iml.

The reinclude either adjust the .iml file, or select the folder (do not right click), then right click in the bread crumb section. In project view the Mark Directory as will be disabled, in bread crumb section it is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment