Odoox is a command-line tool designed to streamline Odoo development workflows. The project contains utilities for managing Odoo modules, configurations, and related development tasks. This document provides an overview of the codebase and detailed explanations of the available features.
- Documentation for the Odoox Project
- Installation
- Usage: Getting Started with
odooxTutorial - Contribute.
Before you begin, ensure that you have the following installed:
- Python (3.8 or higher recommended)
- Pipenv (optional, for creating isolated Python environments)
- Docker
-
Clone the repository:
git clone https://github.com/kajande/odoox.git cd odoox -
Install the project and dependencies:
pip install -e . -
Verify installation:
odoox --help
This guide provides a step-by-step tutorial to help you get started with odoox, a command-line tool designed to simplify and accelerate the Odoo development workflow. Follow these instructions to set up, build, and run an Odoo project effortlessly.
-
Open a terminal and create a new directory for your project:
mkdir test_project cd test_project -
Set up a Python environment (optional):
pipenv install
-
Install odoox within the environment:
- Head to the odoox GitHub repository.
- Copy the installation command provided in the repository:
pip install git+https://github.com/kajande/odoox.git. - Paste and execute the command in your terminal.
-
Once installed, initialize the project structure using:
N.B: Make sure that the directory is empty before running the following command. (Remove any file then put them back later)
odoox p --init
This command generates all the necessary files and folders for your project, including:
- A
Dockerfilefor building the project. - An
odoo.conffile for configuring the Odoo instance. - A pre-populated Odoo module folder named after your project.
- A
-
Build the project with a single command:
odoox build
-
During the build process, observe the logs. You’ll notice that the odoox tool is installed inside the Docker image, enabling you to use it directly within the container.
-
Verify that the build was successful by listing all related images:
odoox im
The output will display the project’s image, named after your project and tagged as
latest.
-
Run the project using:
odoox run
This command:
- Starts a PostgreSQL container.
- Starts an Odoo container connected to the PostgreSQL container.
-
Watch the logs to confirm the base modules are being installed.
-
Access the Odoo application:
- Use the command:
This outputs the URL for accessing the Odoo interface. The port includes the Odoo version for easy identification.
odoox url
- Open the URL in your browser.
- Use the command:
-
Log in to the Odoo interface with the default credentials:
- Username:
admin - Password:
admin
- Username:
-
Activate debug mode in the Odoo interface to view additional details, such as the current database and default module.
-
Manage containers:
odoox ps
Prints the two containers (odoo and postgres) within this project. The two containers are named
{project_name}_odooand{project_name}_pgrespectively.This means that you cannot recreate new containers because you'll get name conflicts. To do that you'll have to remove the existing ones with
odoox rm -og.odoox restart -o odoox restart -g odoox restart -og odoox start -o|-g|-og odoox stop -o|-g|-og odoox rm -o|-g|-og odoox in -o # gets you inside the odoo container odoox in -g # gets you inside the postgres container
- -o targets the odoo container
- -g targets the postgres container
- -og or -go targets both the odoo container and the postgres container
-
Get the access URL:
odoox url
Prints the URL for accessing the Odoo application.
-
List all images:
odoox im
Displays all images built for the project.
odoox im --rm
Removes current image (tagged
latest). -
Tag an image:
odoox tag <tag>
Tags the current
latestimage with a new name, preserving its state. -
Switch to a specific image:
odoox workon <tag>
Assigns the
latesttag to a specified image, ensuring thatodoox runuses it.
With just a few commands, odoox streamlines the process of setting up, building, and running Odoo projects. Explore the tool further to discover more features that simplify your Odoo development workflow.
For additional details, check out the documentation or contribute to the project by submitting issues and pull requests.
Odoox simplifies module development with the base command:
odoox m <module> --optionm: Denotes the subcommand for module-related operations.<module>: The name of the target module.--option: Specifies the operation to perform.
-
Create a Module (Scaffold Base Code):
odoox m my_module --init
Initializes the structure for a new module named
my_module. -
Install a Module:
odoox m my_module -i
Installs the specified module in the active Odoo database.
Installs at the same time all dependencies specified in the
gitx.conffile. Refer to the example in that file:[module11] pulluri = https://github.com/odoox-demo-org/repo1.git branch = track =where:
pullurispecifies the git repository hosting your dependent module[module11]is the name of the your dependent module from that repositorybranchis the name of the branch your are interested in. (default to main)trackis the commit from that branch (default to main)
You may add as many dependencies as you want from same repositories or different repositories.
Note: the repository is downloaded at {project_name/project_name/repos}. Check there!
-
Uninstall a Module:
odoox m my_module --i
Uninstalls the module from the active Odoo database.
-
Activate a Module:
odoox m my_module -a
Activates the module by installing its data and making it ready for use.
-
Deactivate a Module:
odoox m my_module --a
Deactivates the module, effectively disabling it.
-
Update a Module:
odoox m my_module -u
Updates the module's data by reloading XML or other configurations.
-
Restart After Code Changes: If you modify
.pyfiles, restart the server with:odoox restart -o
-
Update After XML Changes: If you modify
.xmlfiles, update the module with:odoox m my_module -u
- Install vs. Activate:
Install: Makes the module available in the database and ready for activation.Activate: Performs the traditional "installation" by loading the module's data and making it usable.
Odoox provides a set of commands to simplify interaction with PostgreSQL databases. The base command is:
odoox db <dbname> --optionsdb: Denotes the subcommand for database-related operations.<dbname>: The name of the database to interact with.--options: Specifies the operation to perform.
-
Create a Database:
odoox db <db_name> -c
Creates a new database named
<project_name>_<db_name>. -
Select a Database:
odoox db <db_name> -s
Selects an existing database for further operations. This sets the current database for module commands.
-
Delete a Database:
odoox db <db_name> -d
Deletes a specific database, useful in cases of severe database inconsistencies.
-
List All Databases:
odoox db <db_name> -l
Lists all databases created under the current project. (TODO)
Do you want additional database operations ? Run the command
odoox in -gto get straight away inside the database and startlisting ordeleting databases.
- Database Name Prefix:
Running any
odoox dbcommand appends the current project name as a prefix to the database name. For example, executing:under a project namedodoox db test -cprojwill create a database namedproj_test.
odoox/
├── odoox/
│ ├── __init__.py
│ ├── __main__.py
│ ├── config.py
│ ├── db.py
│ ├── dockerx.py
│ ├── gitx.py
│ ├── module.py
│ ├── module_init.py
│ ├── odoo_conf.py
│ ├── project.py
├── .gitignore
├── LICENSE
├── README.md
├── requirements.txt
├── setup.py
odoox/: Contains the main logic of the project.setup.py: Installation script for packaging and distribution.requirements.txt: Python dependencies required for the project.README.md: High-level description and instructions for the tool.
Purpose: Handles configuration settings for the project.
- Key Features:
- Load Odoo configurations from files.
- Provide methods for accessing database and Docker settings.
Purpose: Provides database utilities for interacting with Odoo databases.
- Key Features:
- Connect to the PostgreSQL database.
- Execute queries securely.
Purpose: Manages Docker containers running Odoo instances.
- Key Features:
- Restart Docker containers.
- Fetch container details (e.g., IP address).
Purpose: Facilitates Git operations for Odoo projects.
- Key Features:
- Clone repositories.
- Manage Git workflows.
Purpose: Contains logic for managing Odoo modules.
- Key Features:
- Copy and rename Odoo modules.
- Update module configurations.
Purpose: Handles initialization of Odoo modules within the development environment.
- Key Features:
- Automates the creation of Odoo module scaffolding.
Purpose: Manages the odoo.conf configuration file.
- Key Features:
- Read and write Odoo configuration files.
- Update database and path settings.
Purpose: Manages high-level project settings and operations.
- Key Features:
- Set up new Odoo projects.
- Organize project files and directories.
- Refactor code organisation for better readability and further development
- Add more project management features like commands for setting configurations: username, email, etc.
- Integrate an AI assistant for faster development.
You are invited to contribute !
Documentation Last Updated: 2024-12-15