To uninstall modules from an Odoo database using the terminal, you can use the Odoo shell or execute SQL commands directly. Here's how to do it:
-
Launch the Odoo shell:
./odoo-bin shell -d <your_database_name>
-
Uninstall the module: In the shell, execute the following Python code:
module_name = "<module_name>" # Replace <module_name> with the technical name of the module module = env['ir.module.module'].search([('name', '=', module_name)]) if module: module.button_immediate_uninstall() print(f"Module '{module_name}' uninstalled successfully.") else: print(f"Module '{module_name}' not found.")
You can directly mark the module as uninstalled in the database. Be cautious and ensure you have a backup before proceeding.
-
Access the PostgreSQL database:
psql -d <your_database_name>
-
Find the module ID:
SELECT id, name FROM ir_module_module WHERE name = '<module_name>';
-
Mark the module as uninstalled:
UPDATE ir_module_module SET state = 'uninstalled' WHERE name = '<module_name>';
-
Restart Odoo: After modifying the database, restart the Odoo service for the changes to take effect:
sudo systemctl restart odoo
- Dependencies: Uninstalling a module will automatically uninstall dependent modules.
- Data Removal: Module uninstallation does not remove database records unless specified in the module.
- Backup: Always create a database backup before uninstalling modules, especially in a production environment.
thanks, useful