Odoo 8 adding notebook tab via custom module gives 'KeyError:'

367 views Asked by At

I've added an extra notebook tab to 'Project.task' via a small external module, which works when I install.

My problem is, if I try to install any module after I get a 'KeyError'.

If I remove my custom module from 'addons' directory restart server every thing works again.

So it lets me install it with no errors but wont let me upgrade it or install any other modules.

Any pointers would be very appreciated.

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>

So it works to install it, but after if I update or just install another module I get;

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'

I'm obviously missing something simple.

1

There are 1 answers

3
Bhavesh Odedra On

Might be you have forgot to add project module in your dependency.

Whenever you do inherit then make sure that install module in which class/object declared.

Improve your __openerp__ file with following:

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

Now restart Odoo server and upgrade your module.