The main goal is - to create tool for developing on odoo platform, which will meet the following requirements:
- do not depend from operating system
- do not depend from process architecture if it is possible (For example you can start this project on MacOS on M1)
- еo transfer all project information, it is enough to have an
odpm.json
in project repository, and the system will be able to easily prepare a new environment in a fully automatic mode based on it. - To have convenient tools that are often necessary for the developer, for example:
- fast DB recovery from the archive
- сreation of a new DB with its own settings (country, language, demo data, etc.)
- Changing the login and password for the administrator
- ... and more
- mechanisms for extending the functionality, for the future
If you are new, i recommend using this project in conjunction with the training demo https://github.com/aayartsev/odoo_demo_project
.
You need to download and install the following programs:
Create a folder where your new project will be located. At the end of the project name, I add the odoo version number through a hyphen. For example, odoo_demo_project-17
. This is due to the fact that the difference between versions is quite significant and I consider the same modules for different versions as different projects for development, despite the fact that they can be in the same repository. Your project environment will be located in this directory in the future. You need to initiate a new one using the --init
command option, where we can specify a link to the git repository(o link to local directory) and using the --branch
option, we specify the specific branch we want to switch the project under development to:
Launch VSCode
then threw menu File - Open Folder, open our folder odoo_demo_project-17
.
Now we cat enable Terminal threw menu Terminal - New Terminal. Then in it you can input commands that are written below. If someone, looking at a python script, wants to run it inside a virtual environment, then do not do this. In this case, it is used instead of system scripting languages and you will only complicate your life. The virtual environment for the project will be installed inside the container.
At the very first launch of the previously described command:
python3 /path/to/cloned/odoo_dev_project/odpm.py --init git@github.com:aayartsev/odoo_demo_project.git --branch 17.0-test_odpm_json
If you do not wish to contact the git
repository for any reason, you can easily create a local development environment by simply specifying a desired directory location.
python3 /path/to/cloned/odoo_dev_project/odpm.py --init file:///your/path/to/odoo_demo_project-17/name_of_development_directory
The system will try to prepare your computer:
- The system will ask questions about which parameters should be saved to a file
.env
- If you are deploying a project from scratch, the system will ask you to specify the odoo version and make initial settings based on this information
- The cloning process of the main odoo repository will be started. This takes a very significant time of 40 minutes or more, so be patient
- The repository under development will be cloned
- A
Dockerfile
will be automatically generated for the specifiedpython
anddebian
version. - After that, the automatic build of the
Docker image
will start - The
docker-compose.yml
file will be automatically generated - Configuration files will be generated for VS Code for the debugger to work correctly
docker-compose up
will start automatically- All python dependencies will be installed in the virtual environment
- Odoo will start with all specified addons for selected version
You can stop this running process by using the keyboard shortcut Ctrl+C
.
After that, you can run odoo in developer mode:
python3 /path/to/cloned/odoo_dev_project/odpm.py -d test_db -i -u
This command will launch odoo inside the Docker container
and create a new database named test_db
and install the module from the specified project there
After that, you can open the address http://127.0.0.1:8069
in the browser and you will see the login window.
2 configuration files are required for the system to work:
odpm.json
- it also can be located in the repository with the developing project, contains the necessary information on how to start this project. If the file is not found, it will be created from the default values.user_settings.json
- contains the settings and preferences of a specific developer. If the file is not found, it will be created from the default values.
This app build environment for your project. The project itself is a directory that is specified in a parameter developing_project
of user_settings.json
file or as key of --init
param.
The system will try to create a .odpm
directory in the user's home directory of your operating system. Inside it the system will place the .env
file. If you are launching the application for the first time, it will ask a question for each item described below in this file and offer default values. If you don't know what to answer, just press Enter
. If you place the .env
file in the project directory, the program will consider it a priority and try to take values from the file inside the project.
BACKUP_DIR
- the directory where the archives are located. It is used to specify the name of the database for recovery using command-line parameters and then the system will search for an archive with the specified name in this directory, or when saving the database to the archive, it will appear in this directory, can be used for all projectsODOO_SRC_DIR
- The directory where the full clone of the repository of theodoo
platform itself should be located. I usually put it in my user profile. It is used by all projects.ODOO_PROJECTS_DIR
- create a directory where clones of all used repositories will be created. You just need specify the path to this directory, then the system itself will create this directory and clone all the repositories into it and arrange them so that there are no conflictsPATH_TO_SSH_KEY
- if, for some reason, you are unable to add your repository key to the ssh agent, then you can specify the path to it here. At the moment, one key will be used for all repositoriesODOO_PORT
- the port on which odoo will be launched by default at the address 127.0.0.1POSTGRES_PORT
- the port on which the PostgreSQL DBMS will be launched by default at the address 127.0.0.1DEBUGGER_PORT
- the port on which the debugger will run by default at the address 127.0.0.1
Example for Linux:
BACKUP_DIR=/home/user/odoo_backups
ODOO_SRC_DIR=/home/user/odoo
ODOO_PROJECTS_DIR=/home/user/odoo_projects
PATH_TO_SSH_KEY=/home/user/.ssh/my_ssh_key
ODOO_PORT=8069
POSTGRES_PORT=5432
DEBUGGER_PORT=5678
init_modules
-type: String
. Parameter that specifies modules separated by commas, without spaces, which will be initiated (installed) when (re)starting the system.update_modules
-type: String
A parameter that specifies modules separated by commas, without spaces, which will be updated when (re)starting the systemdb_creation_data
-type: Object
. The parameters that determine the creation of a new database.db_lang
-type: String
. Specify the default system language when creating a new database, for example:"en_US"
or"ru_RU"
db_country_code
-type: String
orfalse
. Specify the default country code for creating a new database, for example:"by"
create_demo
-type: Boolean
. Indicates whether it is necessary to create demo data in the system when creating a new database.db_default_admin_login
-type: String
. Login for the administrator accountdb_default_admin_password
-type: String
. The password for the administrator account
update_git_repos
-type: Boolean
. Indicates whether the dependency repositories and odoo itself will be updated when the system is restartedclean_git_repos
-type: Boolean
. Indicates whether changes to odoo itself and dependency projects will be reset on restartcheck_system
-type: Boolean
. Indicates whether the system check will be started at startup. Useful for beginners. Checks ifgit
,docker
, anddocker-compose
are installed.developing_project
-type: String
.A link to the project you are developing. Example:"git@github.com:aayartsev/odoo_demo_project.git "
pre_commit_map_files
-type: String
. A list of files for thepre-commit
system that are taken out of the project and pushed there through the docker file mapping. It is necessary to work on non-Linux systemsdev_mode
-type: String
. You can specify comma-separated parameters for developers. See the official documentation for your version of odoodb_manager_password
-type: String
. password for the database managersql_queries
-type: List
. Contains a list of strings, each of which is an SQL script that will be executed when using the command line parameter--sql-execute
use_oca_dependencies
- added an experimental feature that allows automatically loading all dependencies specified in the"oca_dependencies.txt"
file. The default value isfalse
create_module_links
- an experimental feature that adds soft links for all modules involved in the project to theodoo/odoo/addons
directory. This allows the language server to automatically resolve import paths. The default value isfalse
.
python_version
-type: String
. The python version is indicated in text form by its number, for example"3.10"
or"3.7"
,distro_name
-type: String
. The name of the distribution on which the image for running Odoo will be created. Currently, only"debian"
is supported.distro_version
-type: String
. The version of the distribution specified in the distro_name key, indicated as a text version, for example,"11"
or"12"
odoo_version
-type: String
. The version of the odoo system. Examples:"16.0"
,"15.0"
,"11.0"
dependencies
-type: List
. A list of links to the project repositories on which your project dependsrequirements_txt
-type: List
. A list of python modules, each element can be formatted in the same way as a line in a file requirements.txt
Currently, for Odoo versions 11 to 16 inclusive, Python 3.7 on Debian 11 (Bullseye) has been tested and works stably. Also tested and works stably for Odoo versions 16 to 17 with Python 3.10 on Debian 11 (Bullseye) and Debian 12 (Bullseye). Experimental support for Ubuntu distributions has begun, but it is still in its early stages, and all experiments are at your own discretion. Supported distributions and versions:
- Stable:
- Debian 11 (Bullseye)
- Python 3.7, 3.10
- Debian 12 (Bullseye)
- Python 3.10
- Debian 11 (Bullseye)
- Experimental:
- Ubuntu 22.04 (Jammy)
- Python 3.10
- Ubuntu 20.04 (Focal)
- Python 3.8
- Ubuntu 22.04 (Jammy)
--init
- initiate a project in the current directory. As a parameter, you can specify a link to thegit
repository--branch
- used together with the--init
parameter to specify the branch of the git repository to be cloned.-d
- to specify the name of the database to work with. If there is no such database, it will be automatically created based on thedb_creation_data
parameter from the configuration fileuser_settings.json
-i
- the parameter indicates that the modules specified in theinit_modules
parameter of theuser_settings.json
configuration file should be initialized.-u
- the parameter indicates that the modules specified in thepdate_modules
parameter of theuser_settings.json
configuration file should be updated.-t
- will run tests of modules specified ininit_modules
andupdate_modules
, works only when using parameters-d
,-i
,-u
. If the database is being created from scratch, tests of all installed modules will be run. This may take a long time.--get-dbs-list
- will show list of databases--db-restore
- The system will attempt to restore a database archive. Specify the archive name, which must be located in the directory specified by theBACKUP_DIR
parameter in the.env
file. The database name for restoration will be taken from the-d
parameter.--db-backup
- The system will attempt to create a database archive. You can specify the archive name to be created in the directory specified by theBACKUP_DIR
parameter in the.env
file. If no name is provided, it will be generated automatically based on the database name from the-d
parameter plus a timestamp. The database name for archiving will be taken from the-d
parameter.--db-drop
- accept database name as parameter. Database with selected name will be deleted. If you will use it with params-d
,-i
,-u
, and select the same name, system will with first step delete DB and with second step will create new DB with the same name, and will install selected modules.--translate
- will update translation for selected language, for exampleru_RU
oreu_US
for database from-d
param and for modules formupdate_modules
andinit_modules
fromuser_settings.json
file--pip-install
- will start install of all python packages from odoorequirements.txt
and fromrequirements_txt
param to environment insidedocker container
.--start-precommit
- will start pre-commit for your project inside container, specified in parameterdeveloping_project
from fileuser_settings.json
.--build-image
- will build Docker image for your odoo version--set-admin-pass
- when you specify the value of this parameter, the administrator account will have its password and login changed to those specified in thedb_default_admin_login
anddb_default_admin_password
parameters in theuser_settings.json
configuration file. Be sure to specify the name of the database for which you want to change the password and use the-d database_name
parameter.--sql-execute
- wen this parameter is used, the SQL scripts specified in thesql_queries
parameter of theuser_settings.json
configuration file will be executed. Each script is a separate string that is an element of the list. You must specify the name of the database for which you want to change the password and use the parameter-d database_name
.