How to remove openerp module manually

I installed the module on openerp v7, which I would like to remove.

Using the interface will fail, I get an error message during the uninstall process.

Is there a β€œmanual” way to remove a module? Is it enough to delete the module folder under addons/ or are there any other things to do this in the cleanest way?

Here is the error I get when I try to remove a module through an interface:

 Client Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/web/controllers/main.py", line 1132, in call_button action = self._call_kw(req, model, method, args, {}) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/web/controllers/main.py", line 1120, in _call_kw return getattr(req.session.model(model), method)(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/web/session.py", line 42, in proxy result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/web/session.py", line 30, in proxy_method result = self.session.send(self.service_name, method, *args) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/web/session.py", line 103, in send raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info) Server Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/netsvc.py", line 292, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/osv/osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/base/module/module.py", line 495, in button_immediate_uninstall return self._button_immediate_function(cr, uid, ids, self.button_uninstall, context=context) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/addons/base/module/module.py", line 475, in _button_immediate_function _, pool = pooler.restart_pool(cr.dbname, update_module=True) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/pooler.py", line 39, in restart_pool registry = RegistryManager.new(db_name, force_demo, status, update_module) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/modules/registry.py", line 218, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/modules/loading.py", line 354, in load_modules loaded_modules, update_module) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/modules/loading.py", line 256, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/modules/loading.py", line 188, in load_module_graph load_data(module_name, idref, mode) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/modules/loading.py", line 76, in <lambda> load_data = lambda *args: _load_data(cr, *args, kind='data') File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725- py2.7.egg/openerp/modules/loading.py", line 124, in _load_data tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131016_232725-py2.7.egg/openerp/tools/convert.py", line 945, in convert_xml_import relaxng.assert_(doc) File "lxml.etree.pyx", line 3027, in lxml.etree._Validator.assert_ (src/lxml/lxml.etree.c:129517) AssertionError: Did not expect text in element record content, line 33 

Sorry for this long trace.

At first I suspected that one of the xml files was wrong, but when I try to install the module manually, I think something else is going wrong, but I do not see that.

Greetings

+6
source share
2 answers

Removing module code from addons/ not enough - this will violate OpenERP.

Solution 1 - try to fix the error that you have during normal uninstallation

This method is recommended since OpenERP does the job cleanly. Look at the error you make when uninstalling, and try to imagine what might be the problem. Send the error trace here for more help.

Solution 2 - Manual Uninstall

My procedure is based on OpenERP v6.0, but it should be very similar to OpenERP v7.

  • Backing up the database :). Do this. It is very likely that you will break something during this procedure.

  • Find what records were created during the installation or update of the module.

    • Take a look at __openerp__.py to see which XML files are taken into account when installing and updating the module. Also, review all XML files in the module directories.

    • Search for entries created by these modules during installation or upgrade. There must be XML elements inside these files, such as <record ...model='...'> . The model attribute tells you which database the date is in. If you are using a Unix-like system, you can try the following command in the root directory of the module:

    grep -r -n -A 5 --include="*.xml" \<record *

  • Delete these entries. You will use some database interface tool, for example PgAdmin or pqsl , and find the entries found in the previous step.

    For example, the following XML line defines an entry in ir_cron datatable:

    <record model="ir.cron" id="ir_cron_account_fiscalyear_close">

    Knowing that you can find a record based on the data defined for that record in an XML file.

  • Find and delete all menu items defined by the module. As above, search for XML files for <menuitem ...> elements. Find related entries in ir_ui_menu datatable.

  • Find out which models defined by the module. Try the following command:

    grep -r -n -C 5 --include="*.py" "_name = " *

    Pay attention only to models defined in objects that are derived from osv.osv ( osv.Model in OpenERP v7). They define persistent models stored in the database. A child of osv.osv_memory ( osv.TransientModel in version 7) is not stored in the database.

    Be careful and avoid deleting models defined in parent objects. Take a look at the _inherit property of the object to give you an idea of ​​this. In this case, you want to delete only the columns added by your module.

    Once you find the models defined by your module, try deleting the relevant data. For example, a model with

    _name = "bg_vat.bg_vat"

    will have a corresponding table in the database named 'bg_vat_bg_vat'.

  • Finally, remove or just unplug the module. Find the entry that matches your module in ir_module_module datatable. You can delete the entry or simply set the state field to uninstalled .

    If you like, now you can remove the module directory from addons , but I see no reason for this.

I'm sure I skipped some cleanup actions (for example, writing to the ir_model* data family). I am also sure that this procedure can easily disrupt the installation of OpenERP. Make a backup first. :)

+8
source

Proof of concept: https://www.youtube.com/watch?v=7jtmDM0wfFQ

There are two ways:

  • Apply the patch of my stretch request:

    https://github.com/odoo/odoo/pull/12373.patch (git apply / home / user / patch _file.patch)

  • Manually:

    1.Go to Terminal> psql db_name and run a query like: update ir_module_module set state='to remove' where name='module_name' and state='installed';

    2. Add update_module=True to load.py before this line

And run odoo.py or odoo-bin.

This will remove the module correctly and safely.

Enjoy the ode. Let me know if you have any problems.

+2
source

All Articles