To update and upgrade an Odoo custom module using Docker and avoid using the web interface, you can achieve it by running the necessary commands directly on the Odoo container using docker exec. Here's a step-by-step guide:
1. Updating the Module with Docker
Use the following steps to update your custom module:
Step 1: Locate the Module
Make sure your custom module is located in the directory specified in your docker-compose.yml under:
- ./odoo/addons:/mnt/extra-addons:rw
Ensure the module's updated files are saved in this folder.
Step 2: Run the Upgrade Command
To update the module, use the docker exec command to access the Odoo container and run the -u flag to upgrade the module.
Here’s the command:
docker exec -it odoo_fab17 odoo --dev=reload -d <database_name> -u <module_name>
- Replace <database_name> with the name of your database.
- Replace <module_name> with the technical name of your module.
For example:
docker exec -it odoo_fab17 odoo --dev=reload -d my_db -u my_custom_module
2. Automating Module Updates with docker-compose
If you want the custom module to automatically update when you rebuild or restart your containers, you can add the upgrade command to your docker-compose.yml.
Modify docker-compose.yml
Update the command section in your Odoo service:
command: >
-- --dev=reload
-d <database_name>
-u <module_name>
Example:
command: >
-- --dev=reload
-d my_db
-u my_custom_module
Whenever you restart your containers, the module will automatically be upgraded.
3. Restart the Odoo Container
After making changes to your module or docker-compose.yml, restart your containers:
docker-compose down
docker-compose up -d
This ensures the latest module files are loaded and the upgrade command is executed.
4. Rebuilding Assets (Optional)
If your module includes JavaScript or CSS changes, you may need to rebuild Odoo assets. Run the following command:
docker exec -it odoo_fab17 odoo --dev=reload -d <database_name> -u <module_name> --load=web.assets_backend
5. Verifying the Update
- After running the command or restarting the container, log in to Odoo.
- Check if the custom module has been updated with the latest changes.
6. Debugging Tips
If the module does not update or errors occur:
- Check the Odoo logs for issues:
docker logs odoo_fab17
- Ensure the custom module is correctly located in the addons folder.
- Verify the module's manifest file (__manifest__.py) for any syntax issues.
This process avoids using the Odoo web interface and allows you to manage custom module updates directly from the command line using Docker. Let me know if you have further questions or encounter issues!