Wouldn’t it be cool to do things in OpenERP via simple python scripts that you could launch from the console ? Fortunately , OpenERP has been designed to help with this.
The RegistryManager class (openerp.modules.registry.RegistryManager) is so awesome that it only takes a single line to get a working pool. You can then start coding right away.
import openerp pool = openerp.modules.registry.RegistryManager.get("test")
There. You have your pool that is connected to the « test » database. You can start playing with it immediately.
import openerp pool = openerp.modules.registry.RegistryManager.get("test") # get a valid cursor (for browse, search etc.) cr = pool.db.cursor() # get the superadmin user ID to have special powers uid = openerp.SUPERADMIN_ID # get the module object from the pool module = pool.get("ir.module.module") # We want to uninstall the "helloworld" module for instance uninstall_id = module.search(cr,uid,[("name","=","helloworld")])[0] # Get the module object uninstall_module = module.browse(cr,uid,uninstall_id) # Call its "module_uninstall" method uninstall_module.module_uninstall() # Done !