Odoo Help

12
13 Answers
3
Justin
11/17/14, 5:45 PM

It should be possible to uninstall modules programmatically, because then you can script it for automation.

Having to manually log in to a system to perform administrative functions is error prone and tedious for repetitive tasks. In 2014, every GUI operation should have an API command that does the same thing.

I'm scripting an upgrade path for my 6.1 version database and this is making my testing more difficult than it needs to be.

4 Comments
Justin
11/18/14, 2:09 AM

I found a way to do it. Set the state column in ir_module_module for the module to 'to remove' similar to this: psql -c "UPDATE ir_module_module SET state = 'to remove' WHERE name = '';" and then perform a commandline update: openerp-server -u The update will trigger the module removal.

Royal Administrator
2/16/16, 12:20 AM

Gratitude. Solved it for me with Odoo 9, given I inserted this patch as step 2A in openerp/modules/loading.py, and then commented the corresponding two lines of code at the top of STEP 5. Of course, be careful everybody.... # 13.0.3.3.11-t11 jrook STEP 2A: Before step 3, setup list of modules to remove later during step 5. # since 'to remove' modules will be loaded during step 3 and will exit step 3 in 'installed' state. cr.execute("SELECT name, id FROM ir_module_module WHERE state=%s", ('to remove',)) modules_to_remove = dict(cr.fetchall())

Royal Administrator
2/16/16, 12:23 AM

Try for better indent this time... # 13.0.3.3.11-t11 jrook STEP 2A: Before step 3, setup list of modules to remove later during step 5. # since 'to remove' modules will be loaded during step 3 and will exit step 3 in 'installed' state. cr.execute("SELECT name, id FROM ir_module_module WHERE state=%s", ('to remove',)) modules_to_remove = dict(cr.fetchall())

Ermin Trevisan
3/22/16, 11:09 AM

Whoever did it, I do not see a reason to flag this post, so please explain or leave it as is.

5
NUMERIGRAPHE
3/12/15, 2:57 PM

You can uninstall a module using the XML-RPC API.

Here is the script I use for v7 (it probably works in later version too).

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""Uninstall a module"""

import xmlrpclib
import argparse
import getpass

parser = argparse.ArgumentParser()
# Connection args
parser.add_argument('-d', '--database', help="Use DB as the database name",
                    action='store', metavar='DB', default=getpass.getuser())
parser.add_argument('-u', '--user', help="Use USER as the database user name",
                    action='store', metavar='USER', default='admin')
parser.add_argument('-w', '--password',
                    help="Use PASSWORD as the database password.",
                    action='store', metavar='PASSWORD', default='admin')
parser.add_argument('-s', '--url',
                    help="Point to the web services hosted at URL",
                    action='store', metavar='URL',
                    default='http://localhost:8069')
# Feature args
parser.add_argument('module', help="Uninstall the module MODULE",
                    action='store', metavar='MODULE')

args = vars(parser.parse_args())

# Log in
ws_common = xmlrpclib.ServerProxy(args['url'] + '/xmlrpc/common')
uid = ws_common.login(args['database'], args['user'], args['password'])
print "Logged in to the common web service."
# Get the object proxy
ws_object = xmlrpclib.ServerProxy(args['url'] + '/xmlrpc/object')
print "Connected to the object web service."

# Find the parent location by name
res_ids = ws_object.execute(
    args['database'], uid, args['password'],
    'ir.module.module', 'search', [('name', '=', args['module'])])
if len(res_ids) != 1:
    raise Exception("Search failed")

# Uninstall the module
print "Uninstalling '%s'" % args['module']
ws_object.execute(
    args['database'], uid, args['password'],
    'ir.module.module', "button_immediate_uninstall", res_ids)

print "All done."

3
Devendra Kavthekar
2/1/17, 2:06 AM

My stackoverflow answer:

http://stackoverflow.com/questions/21485630/how-to-uninstall-manually-openerp-module/41760541#41760541


There are two ways
    1.Apply the Patch of my pull request:
            https://github.com/odoo/odoo/pull/12373.patch (git apply /home/user/patch_file.patch)
    2.Manually:

  • Go to Terminal > psql db and Execute the query like: update ir_module_module set state='to remove' where name='module_name' and state='installed';

  • Add update_module=True in loading.py before this line > https://github.com/odoo/odoo/blob/10.0/odoo/modules/loading.py#L378

And run the odoo.py or odoo-bin.
This will uninstall the module properly and safely.

Let me know if face any problem.

0
Devendra Kavthekar
4/18/18, 1:17 AM

You can use the patch of the Pull request for your own odoo:

https://github.com/odoo/odoo/pull/12373


Odoo sees this as opening a loophole/vulnerability, so they don't want this feature to be available.

1 Comment
ANDRES PENAGOS
2/8/19, 9:01 AM

DevendraK i download https://github.com/odoo/odoo/blob/10.0/odoo/modules/loading.py and apply patch directions from https://github.com/odoo/odoo/pull/12373 (april2018) . I am using " --uninstall

module_name" but it does not uninstall the module. do I still have to use

Add update_module=True in loading.py (feb 2017 comment)???

thaks a lot

0
Avatar

Gopakumar N G

--Gopakumar N G--
1248
| 5 4 8
Cochin, India
--Gopakumar N G--

Project Lead at Bizweaver Technologies Pvt. Ltd.

Gopakumar N G
11/11/13, 7:39 AM

There is no way to uninstall a module from terminal. You can check the possible options by running
./openerp-server --help in terminal.

0
Gavin Yap
3/22/16, 12:24 AM

You can now do it using odoorpc library.

I've did an example of installation here

https://github.com/maclarensg/odoo_module_install_script,

You probably can modify it to uninstall. 

-1
Pavel Pavlov
3/22/16, 5:59 AM

Hello,

I don't think there is a command line to do that. The only option that is supported as far as i know is the Settings -> Apps -> <the module=""> -> Uninstall. In general uninstall is not smart idea... you need to be extra careful.

Regards, Pavel Pavlov

-1
Roberto Barreiro
4/1/16, 3:44 PM

My bad...

-2
Avatar

Navrang Oza

--Navrang Oza--
Navrang Oza
843
| 3 2 6
Gandhinagar, India
--Navrang Oza--

Having 13+ years of experience in Odoo, Magento, Wordpress, Android, PHP Expert.

Skype : acespritech

Email : info@acespritech.com

Navrang Oza
11/11/13, 2:09 AM

Hi,

I think there is no way to uninstall module from command line but temporarily you may cut module(the module you want to uninstall) from your addons path. It is not the best way but atleast it will let you know the issue.

Ask a Question
Writer
Tag
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now