Odoo 8通过自定义模块添加笔记本选项卡给出'KeyError:'

时间:2016-12-17 12:21:15

标签: python openerp odoo-8 keyerror

我通过一个小型外部模块为'Project.task'添加了一个额外的笔记本标签,该模块在我安装时有效。

我的问题是,如果我在得到'KeyError'后尝试安装任何模块。

如果我从'addons'目录重新启动服务器中删除我的自定义模块,那么每件事情都会再次运行。

所以它让我安装它没有任何错误,但不会让我升级它或安装任何其他模块。

任何指针都将非常感激。

task_eval.py

from openerp import models, fields
class task_evaluation(models.Model):

    _inherit = 'project.task'

task_eval.xml

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="modify_view_task">
        <field name="name">project.task.form</field>
        <field name="model">project.task</field>
        <field name="inherit_id" ref="project.view_task_form2"/>
        <field name="arch" type="xml">

            <page string="Extra Info" position="after">
                <page name="task_eval" string="Task Evaluation">
                </page>
            </page>

        </field>
        </record>
    </data>
</openerp>

所以它可以安装它,但如果我更新或只是安装另一个模块我得到;

Odoo Server Error
Traceback (most recent call last):
  File "C:\Odoo_8\server\.\openerp\http.py", line 544, in _handle_exception
  File "C:\Odoo_8\server\.\openerp\http.py", line 581, in dispatch
  File "C:\Odoo_8\server\.\openerp\http.py", line 317, in _call_function
  File "C:\Odoo_8\server\.\openerp\service\model.py", line 118, in wrapper
  File "C:\Odoo_8\server\.\openerp\http.py", line 314, in checked_call
  File "C:\Odoo_8\server\.\openerp\http.py", line 810, in __call__
  File "C:\Odoo_8\server\.\openerp\http.py", line 410, in response_wrap
  File "C:\Odoo_8\server\openerp\addons\web\controllers\main.py", line 948, in call_button
  File "C:\Odoo_8\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
  File "C:\Odoo_8\server\.\openerp\api.py", line 268, in wrapper
  File "C:\Odoo_8\server\openerp\addons\base\module\module.py", line 534, in button_immediate_upgrade
  File "C:\Odoo_8\server\.\openerp\api.py", line 268, in wrapper
  File "C:\Odoo_8\server\openerp\addons\base\module\module.py", line 495, in _button_immediate_function
  File "C:\Odoo_8\server\.\openerp\modules\registry.py", line 370, in new
  File "C:\Odoo_8\server\.\openerp\modules\loading.py", line 351, in load_modules
  File "C:\Odoo_8\server\.\openerp\modules\loading.py", line 255, in load_marked_modules
  File "C:\Odoo_8\server\.\openerp\modules\loading.py", line 152, in load_module_graph
  File "C:\Odoo_8\server\.\openerp\modules\registry.py", line 163, in load
  File "C:\Odoo_8\server\.\openerp\models.py", line 595, in _build_model
  File "C:\Odoo_8\server\.\openerp\modules\registry.py", line 102, in __getitem__
KeyError: 'project.task'

我显然错过了一些简单的事情。

1 个答案:

答案 0 :(得分:2)

您可能忘记在依赖项中添加项目模块。

每当你继承时,请确保在声明类/对象的安装模块。

使用以下内容改进__openerp__文件:

'depends': [
    ....,
    ....,
    ....,
    'project'
]

现在重新启动Odoo服务器并升级您的模块。