Skip to content
Snippets Groups Projects
README.rst 7.68 KiB
Newer Older
============
Odoo Scripts
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
============

Most commands can be run directly or with the image build from ``Dockerfile`` (xcgd/odoo_scripts) by indicating the command to run.

Shell scripts
=============

Those scripts are not installed when installing this python module.

Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
start
-----

This script can be used to start odoo.

It need to be run on a machine with all the odoo requirements installed, either system-wide or in a virtual environment (which need to be activated).

Its arguments are forwarded to the Odoo executable (``odoo-bin`` / ``openerp-server``).
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed

It expect the configuration file (`setup.cfg`_) to have the following keys:

Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
- ``odoo_type``: type of odoo (odoo7, odoo8, odoo10, odoo11 or odoo13) [default to odoo8]. The environment variable ODOO_TYPE can be used instead.
- ``modules``: list of directories and files to include (also used by another script)
The environment variable ODOO_ADDONS_PATH can be used to set the path for the addons, it can be empty if there is no path to include.
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
do_tests
--------

This script create a database, install modules and run the tests on those modules and print the result.

It need to be run on a machine with all the odoo requirements installed, either system-wide or in a virtual environment (which need to be activated).
A postgresql server is also needed.

It takes three optional arguments (those are positional arguments):

- the host of the postgresql server,
- the user for this base (which need database creation rights). If a user is provided, you will need to have a .pgpass with the password if it is not the one in ``conf/dev/odoo.conf``.
- the name of the database to use

Those environment variables are used:

ODOO_NO_DROP
  set to reuse an existing database.
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed

The script call `run_tests`_.
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed

It expect the configuration file (`setup.cfg`_) to have the following keys:
- ``module_list``: list (separated by white space) of odoo modules to install on the database (default to empty list)
- ``unaccent``: boolean to indicate if unaccent is to be installed on the database (default to True)
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
run_tests
---------

This script run the tests on a database.

It need to be run on a machine with all the odoo requirements installed, either system-wide or in a virtual environment (which need to be activated).
A postgresql server is also needed.

The name of the database is the same as do_tests or can be provided.

The script call `start`_.
It expect the configuration file (`setup.cfg`_) to have the following keys:
- ``module_list_tests``: list (separated by white space) of odoo modules to run tests for on the database (default to empty list)
- ``odoo_type``: type of odoo (bzr, odoo7, odoo8 or odoo10) [default to odoo8]
create_archive
--------------

zsh script to create a tar.xz file containing all sources.

isort
-----

Run dockerized isort on current directory. This uses a configuration file that is adapted to OCA guidelines for imports.

For help:

.. code-block:: SH

    ./isort --help

Scripts
=======

Those scripts are available when installing the package, and can also be run directly.

The recommend way to install this module is to run ``pip3 install -e .``.

conf2reST.py
This script is used to produce a reST file from setup.cfg, the Dockerfile and the ``.hgconf``/``nest.yaml`` file.
When the package is installed, the executable for this script is ``conf2reST``.

update_duplicate_sources
------------------------

This script will update a metaproject that only contain the sources of the one it is launched from.

It expect the configuration file (`setup.cfg`_) to have the following keys:
- ``modules``: list of directories and files to include (also used by another script)
- ``dependencies``: list of directories and files to include (also used by another script)
- ``other_sources``: list of directories and files to include (only used by this script, used for README, ReleaseNotes, script directories, etc.)
 
No change are made to the name of the directories/files included.
docker_dev_start.py
-------------------

This script can be used to start an odoo from a docker but with the local addons modules mounted.

Using it avoids having to create a virtual env for every project.

Before you use this script, you need to install these packages:

.. code-block:: sh

  apt install python3-docker python3-psycopg2 python3-requests
Your user also needs to be in the docker group.

It expect the configuration file (`setup.cfg`_) to have the following keys:

- ``modules``: list of directories and files to include
- …

When the package is installed, the executable for this script is ``docker_dev_start``.

docker_build.py
---------------

This script builds a docker image of the project.

It uses the super project’s `setup.cfg`_ and ``Dockerfile``.

When the package is installed, the executable for this script is ``docker_build``.

do_tests.py
-----------
This scripts launches the tests, but with more options than `do_tests`_. It uses docker by default, similar to `docker_dev_start.py`_.

When the package is installed, the executable for this script is ``do_tests``.

import_base_import and import_jsonrpc
--------------------------------------

Import CSV files into an odoo.

import_base_import uses odoo base_import module to import the CSV file.
import_jsonrpc uses jsonrpc calls to import the files.
The format is the same as the one used with the import module, with a couple more restrictions:

- selection fields must use the technical value, not the displayed value or one of its translation.
- many2one and many2many fields must use the xmlid of the field they are referencing, with the column name in the form field_name/id or field_name:id.
- one2many fields in the same file are not supported for now,
- date and datetime must be in ISO format.
- context does not include base.import usual import key, so they need to be added as argument or in the configuration file.

import_jsonrpc tries to find an `import.yaml` file alongside any imported file. It will use the delimiter indicated in the file if it finds one and will add the context key to the context used in the jsonrpc calls.
setup.cfg

The scripts expects configuration in the odoo_scripts section of ``setup.cfg``. This file is in the super project, not the one in ``odoo_scripts``.

Configuration keys:

modules
    list of modules to install (relative to project directory), those modules are the ones copied in the Dockerfile
odoo_type
Vincent Hatakeyama's avatar
Vincent Hatakeyama committed
    type of odoo (odoo7, odoo8, odoo10, odoo11, odoo13)
pg.extensions
    postgresql extensions to install (unaccent is added automatically depending on odoo configuration)
load-language
    languages to install into a newly created database
========================

Your ``.zshrc`` should contain a line like this::

  fpath=(~/.local/share/zsh/completion $fpath)

Create completion directory::

  mkdir -p ~/.local/share/zsh/completion

Clone::

  cd
  mkdir -p src
  cd src
  git clone git@github.com:RobSis/zsh-completion-generator.git

Generate completion file for python scripts (from the superproject for the scripts that need to be run from there, and with the required requirements too)::

  docker_dev_start --help | ~/src/zsh-completion-generator/help2comp.py docker_dev_start > ~/.local/share/zsh/completion/_docker_dev_start
  do_tests --help | ~/src/zsh-completion-generator/help2comp.py do_tests > ~/.local/share/zsh/completion/_do_tests
  conf2reST --help | ~/src/zsh-completion-generator/help2comp.py conf2reST > ~/.local/share/zsh/completion/_conf2reST
  import_base_import --help | ~/src/zsh-completion-generator/help2comp.py import_base_import > ~/.local/share/zsh/completion/_import_base_import
  import_jsonrpc --help | ~/src/zsh-completion-generator/help2comp.py import_jsonrpc > ~/.local/share/zsh/completion/_import_jsonrpc