-
Vincent Hatakeyama authoredVincent Hatakeyama authored
Odoo Scripts
Installation
Most commands can be run directly or with the image build from Dockerfile
(xcgd/odoo_scripts) by indicating the command to run, but the best way to use this module is to install it. Installing will also install dependencies.
The recommend way to install this module is to run python3 -m pip install hg+https://orus.io/xcg/odoo_scripts#egg=odoo_scripts
.
Some scripts are in other sections, because they need some specialized library, in that case you need to indicate the name of section as in python3 -m pip install "hg+https://orus.io/xcg/odoo_scripts#egg=odoo_scripts[docker]"
.
The prerequisites for this module or one of its section can be installed by using pip3 or the package manager; the requirements are defined in setup.py
.
To upgrade Odoo scripts, just add --upgrade
to the end of the command.
It can also be cloned it before running python3 -m pip install .
in the clone directory.
Important
As there is no way of indicating sections (worse, it is handling them incorrectly), do not use python3 setup.py install
.
Note that shell scripts are not installed, as they are meant to be replaced with more easily maintanable python scripts.
Scripts
Those scripts are available when installing the package, and can also be run directly.
docker_black
Run dockerized black on provided directory. black must be present in the project image.
This is part of the docker section.
docker_build_doc
Build documentation in docker. It runs make html so could potentially be used to do something else.
This is part of the docker section.
docker_isort
Run dockerized isort on current directory. This uses a configuration file that is adapted to OCA guidelines for imports.
This is part of the docker section.
docker_pylint
Run dockerized pylint on provided module name. Pylint must be present in the project image.
This is part of the docker section.
docker_prettier
Run dockerized prettier on provided directory. prettier must be present in the project image.
This is part of the docker section.
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
.
This is part of the conf2reST section.
update_duplicate_sources.py
This script will update a project 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.) -
duplicate_repo
: target repository, if none are specified, uses the same URL and append _sources to it.
No change are made to the name of the directories/files included.
When the package is installed, the executable for this script is update_duplicate_sources
.
This is part of the source_control section.
docker_dev_start.py
This script starts an odoo from a docker but with the local addons modules mounted, and eventually a local copy of the odoo sources mounted too.
Using it avoids having to create a virtual environment for every project.
Prerequisites:
-
Your user needs to be in the docker group.
-
It expects the configuration file 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
.
This is part of the docker section.
docker_pg.py
This script start a postgresql server the same way docker_dev_start.py does.
By default it provides an interactive psql shell, but can also be used to run SQL commands, use an interactive shell or a shell command.
Prerequisites:
- Your user needs to be in the docker group.
- It uses the configuration file’s keys: postgresql_version.
This is part of the docker section.
docker_rednerd.py
This script is used to start a rednerd server.
It runs the migration on the database before setting values if provided the argument to do so while the server is live.
Prerequisites:
- Your user needs to be in the docker group.
- It uses the configuration file’s keys: rednerd_repository and rednerd_version (defaults to latest).
This is part of the docker section. When the package is installed, the executable for this script is docker_rednerd
.
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
.
This is part of the docker section.
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.
import_sql
Import CSV files into an Odoo database. The import is done directly as SQL insert and update commands.
The format is the similar to the one used with the import module, with many more restrictions:
- selection fields must use the technical value, not the displayed value or one of its translation.
- many2one and many2many fields can not be used.
- one2many fields in the same file are not supported.
- date and datetime must be in ISO format.
When inserting, the create_uid/write_uid are not set.
create_date and write_date is updated as needed, and so is the date_update in ir.model.data
.
This is part of the import_sql section.
odoo_conf_inject_env_var
This script takes an odoo configuration file and a path and will use environment variables values to set some values in the produced odoo configuration file.