Skip to content

Instantly share code, notes, and snippets.

@Sinnnnak
Created December 3, 2024 17:04
Show Gist options
  • Select an option

  • Save Sinnnnak/24a852684cd45978cb54b51549d4b96e to your computer and use it in GitHub Desktop.

Select an option

Save Sinnnnak/24a852684cd45978cb54b51549d4b96e to your computer and use it in GitHub Desktop.
Uninstall modules from terminal

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:


Method 1: Using Odoo Shell

  1. Launch the Odoo shell:

    ./odoo-bin shell -d <your_database_name>
  2. 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.")

Method 2: Using SQL Commands

You can directly mark the module as uninstalled in the database. Be cautious and ensure you have a backup before proceeding.

  1. Access the PostgreSQL database:

    psql -d <your_database_name>
  2. Find the module ID:

    SELECT id, name FROM ir_module_module WHERE name = '<module_name>';
  3. Mark the module as uninstalled:

    UPDATE ir_module_module SET state = 'uninstalled' WHERE name = '<module_name>';
  4. Restart Odoo: After modifying the database, restart the Odoo service for the changes to take effect:

    sudo systemctl restart odoo

Notes

  • 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.
@awmc000
Copy link

awmc000 commented Dec 11, 2025

thanks, useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment