如何手动卸载openerp模块 [英] How to uninstall manually openerp module

查看:77
本文介绍了如何手动卸载openerp模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在openerp v7上安装了要卸载的模块.

I have installed a module on openerp v7 that I would like to uninstall.

使用界面失败,在卸载过程中出现错误.

Using the interface fails, i get an error during the uninstall process.

是否有手动"方式卸载模块?删除addons/下的模块文件夹是否足够,或者有其他要做的事情以最干净的方式进行?

Is there a 'manual' way to uninstall a module ? Is it sufficient to remove the module folder under addons/ or is there any other things to do, to make it in the cleanest way ?

这是我尝试通过界面卸载模块时遇到的错误:

Here is the error I get when i try to uninstall a module through the 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..

起初,我怀疑其中一个xml文件有误,但是当我尝试手动安装模块时遇到相同的错误,我认为还有其他问题,但是我看不到什么.

At first I suspected one of the xml files to wrong, but as I get the same error when I try to install a module manually, I think something else is going wrong but I can't see what.

欢呼

推荐答案

addons/中删除模块的代码还不够-这会破坏OpenERP.

Removing the module's code from addons/is not enough - this will break OpenERP.

解决方案1-尝试解决正常卸载期间出现的错误

建议使用此方法,因为OpenERP可以干净地完成工作.查看卸载过程中出现的错误,并尝试想象可能是什么问题.在此处发布错误跟踪以获取更多帮助.

This method is recommended because OpenERP does the job cleanly. Look at the error you have during uninstallation and try to imagine what could be the problem. Post the error trace here for further help.

解决方案2-手动卸载

我的过程基于OpenERP v6.0,但在OpenERP v7中应该非常相似.

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

  1. 备份数据库:).做吧在此过程中很可能会破坏某些东西.

  1. Backup your database :). Do it. It's very probable that you break something during this procedure.

查找在安装或更新模块期间创建了哪些记录.

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

  • 查看__openerp__.py,以了解在安装和更新模块时要考虑哪些XML文件.或者,考虑模块目录中的所有XML文件.

  • Look at __openerp__.py to see which XML files are taken into account when installing and updating the module. Alternatively, consider all XML files in the module's directories.

在安装或更新期间搜索此模块创建的记录.这些文件中应该有XML元素,如<record ...model='...'>. model属性告诉您记录位于哪个数据表中.如果使用的是类似Unix的系统,则可以在模块的根目录中尝试以下命令:

Search for records created by this modules during install or update. There should be XML elements like <record ...model='...'> inside these files. The model attribute tells you in which datatable the record resides. If you are using a Unix-like system, you can try the following command in the module's root directory:

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

删除这些记录.您将使用诸如PgAdminpqsl之类的数据库接口工具,并找到在上一步中发现的记录.

Delete these records. You'll use some database interface tool such as PgAdmin or pqsl and find the records discovered in the previous step.

例如,以下XML行定义了ir_cron数据表中的一条记录:

For example, the following XML line defines a record in the ir_cron datatable:

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

了解到,您可以基于XML文件中为此记录定义的数据来查找记录.

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

查找并删除该模块定义的所有菜单项.如上所述,在XML文件中搜索<menuitem ...>元素.在ir_ui_menu数据表中查找相关记录.

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

发现模块定义了哪些models.尝试以下命令:

Discover which models were defined by the module. Try the following command:

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

仅注意从osv.osv(在OpenERP v7中为osv.Model)派生的对象中定义的模型.它们定义了存储在数据库中的持久性模型. osv.osv_memory(v7中的osv.TransientModel)的后代对象未存储在数据库中.

Only pay attention to models defined in objects that derive from osv.osv (osv.Model in OpenERP v7). They define persistent models stored in the database. Objects descendant from osv.osv_memory (osv.TransientModel in v7) are not stored in the database.

请小心,避免删除在父对象中定义的模型.查看对象的_inherit属性,以使您对此有所了解.在这种情况下,您只想删除模块添加的列.

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

一旦发现模块定义的模型,请尝试删除相应的数据表.例如,带有

Once you discover the models defined by your module, try to delete the corresponding datatables. For example, the model with

_name = "bg_vat.bg_vat"

在数据库中将有一个名为'bg_vat_bg_vat'的对应表.

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

最后,卸下或仅停用该模块.在ir_module_module数据表中查找与您的模块相对应的记录.您可以删除记录,也可以将state字段设置为uninstalled.

Finally, remove or just deactivate the module. Look for a record corresponding to your module in ir_module_module datatable. You can delete the record or just set the state field to uninstalled.

如果愿意,您现在可以从addons删除模块的目录,但是我看不出这样做的理由.

If you like, you can now delete the module's directory from addons but I don't see a reason to do this.

我确定我错过了一些清理操作(例如ir_model*数据表家族中的记录).我也很确定此过程可以轻松中断您的OpenERP安装.首先进行备份. :)

I'm sure I missed some cleaning actions (like the records in the ir_model* datatable family). I'm also pretty sure this procedure can easily break your OpenERP installation. Make a backup first. :)

这篇关于如何手动卸载openerp模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆