Skip to main content

How to Uninstall an Odoo Module via Command Line (CLI)

How to Uninstall an Odoo Module via Command Line (Odoo Shell Guide)

Uninstalling an Odoo module from the user interface is straightforward — until it isn’t. If your instance is broken, the UI won’t load, or a custom module causes errors, the safest way to proceed is to uninstall the module using the Odoo command line (CLI).

In this guide, you'll learn how to uninstall an Odoo module using the Odoo shell, when to use it, and how to avoid common mistakes that can break your database.


When Should You Use the Command Line?

The CLI method is especially useful in the following situations:

  • The Odoo web interface is not accessible
  • A module causes server startup errors
  • You are working on a remote or headless server
  • You are debugging or developing custom modules
  • You need more control over the uninstall process

Step-by-Step: Uninstall a Module Using Odoo Shell

1. Start the Odoo Shell

Navigate to your Odoo installation directory and run:

./odoo-bin shell -d your_database_name

This opens an interactive Python shell with access to the Odoo ORM through the env object.

2. Locate the Module

Search for the module by its technical name:

module = env['ir.module.module'].search([
    ('name', '=', 'your_module_name')
])

Make sure you are using the technical name (not the display name shown in the UI).

3. Uninstall the Module

module.button_immediate_uninstall()

This will trigger the full uninstall process, including:

  • Removing module data from the database
  • Dropping related models and fields
  • Cleaning up access rules and views

What Actually Happens During Uninstall?

Understanding this is critical before running the command.

When you uninstall a module in Odoo:

  • All records created by the module are deleted
  • Custom fields added by the module are removed
  • Database schema changes introduced by the module are reversed
  • Dependencies are checked and enforced

This means uninstalling is destructive — you cannot recover data unless you have a backup.


Common Issues and How to Fix Them

1. Module Not Found

env['ir.module.module'].search([])

Run this to list available modules and confirm the correct name.

2. Dependency Errors

If Odoo refuses to uninstall the module, it likely means another module depends on it.

Solution:

  • Uninstall dependent modules first
  • Or inspect dependencies via the Apps menu (if accessible)

3. Access Rights Issues

Make sure you're running the shell with sufficient permissions (usually the same user running Odoo).

4. Broken State / Partial Install

If a module is stuck in a broken state, you may need to force cleanup or manually adjust its state in the database.


Advanced Tip: Check Module State Before Uninstall

module.state

Possible values include:

  • installed
  • to upgrade
  • to remove

Only modules in the installed state can be safely uninstalled.


Best Practices Before Uninstalling

  • Always backup your database before uninstalling
  • Test the uninstall process in a staging environment
  • Review module dependencies carefully
  • Restart Odoo after uninstalling
  • Check logs for hidden errors

FAQ

Does uninstalling an Odoo module delete data?

Yes. All data created by the module will be permanently removed.

Can I reinstall the module later?

Yes, but previously deleted data will not be restored unless you have a backup.

Is it safe to uninstall modules in production?

Yes, but only if you understand the impact and have a proper backup strategy.

What if Odoo crashes after uninstall?

Check logs immediately and ensure no dependent modules were left in a broken state.


Conclusion

Uninstalling an Odoo module via the command line is a critical skill for developers and system administrators. It gives you full control over your environment and allows you to recover from issues that the UI cannot handle.

Once you get comfortable with the Odoo shell, you'll find it indispensable for debugging, maintenance, and advanced operations.

Comments

Popular posts from this blog

Use CS50 Library in Your Local Machine Offline (C Language Setup)

Use CS50 Library in Your Local Machine Offline (C Language Setup) Make Your PC Ready for C Programming with CS50 In this guide, you will learn how to prepare your computer to run C programs locally and use the CS50 library offline. The following videos will walk you through all required tools and setup steps. Step 1: Install Visual Studio Code This video explains how to download and install Visual Studio Code on Windows 10. Step 2: Install C/C++ Compiler (GCC, G++, GDB) Learn how to install the C/C++ toolchain using MinGW-w64 and MSYS2. Step 3: Configure VS Code for C/C++ This step shows how to properly configure Visual Studio Code for C and C++ programming. How to Use CS50 Library Offline After completing the setup above, follow these steps to use the CS50 library locally without internet access: Download the CS50 library from GitHub Releases: https://github.com/cs50/libcs50/rel...

How to Open Port 80 and 443 in FirewallD (HTTP & HTTPS Guide)

How to Open Port 80 and 443 in FirewallD (HTTP & HTTPS Guide) If you're running a web server on Linux, you need to open port 80 (HTTP) and port 443 (HTTPS) in your firewall to allow incoming traffic. This guide shows how to open ports in FirewallD using simple commands. 🚀 Allow Port 80 & 443 in FirewallD Use the following commands to allow HTTP and HTTPS traffic: sudo firewall-cmd --zone=public --add-port=80/tcp sudo firewall-cmd --zone=public --add-port=443/tcp These rules are temporary and will be removed after a reboot. Make Rules Permanent sudo firewall-cmd --permanent --zone=public --add-port=80/tcp sudo firewall-cmd --permanent --zone=public --add-port=443/tcp Reload FirewallD to apply changes: sudo firewall-cmd --reload 🔍 Verify Open Ports Check if ports 80 and 443 are open: sudo firewall-cmd --permanent --zone=public --list-ports Expected output: 80/tcp 443/tcp ❌ Remove Ports from FirewallD If you want to close the ...