1

I am trying to add my own custom made module in odoo for test purpose. However, I am continuously getting the below error. Below is how my code looks like. Please help in this regard

_init.py

import select_custom

select_custom.py

from openerp.osv import osv, fields

class select_custom(osv.Model):
    _inherit = 'select.custom'

    _columns = {
        'productChoose' : fields.many2one('hr.employee', 'Product Choose')
        }

select_custom_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_custom_tick_box_form" model="ir.ui.view">
            <field name="name">res.custom.tick.form.inherit</field>
            <field name="model">select.custom</field>
            <field name="inherit_id" ref="purchase.purchase_order_form"/>
            <field name="arch" type="xml">
                <field name="date_order" position="after">
                    <field name="productChoose"/>
                </field>
            </field>
        </record>
    </data>
</openerp>

I am getting the below error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\http.py", line 537, in _handle_exception
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\http.py", line 574, in dispatch
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\http.py", line 310, in _call_function
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\service\model.py", line 113, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\http.py", line 307, in checked_call
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\http.py", line 803, in __call__
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\http.py", line 403, in response_wrap
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\openerp\addons\web\controllers\main.py", line 948, in call_button
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\api.py", line 241, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\openerp\addons\base\module\module.py", line 450, in button_immediate_install
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\api.py", line 241, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\openerp\addons\base\module\module.py", line 498, in _button_immediate_function
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\modules\registry.py", line 370, in new
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\modules\loading.py", line 355, in load_modules
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\modules\loading.py", line 255, in load_marked_modules
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\modules\loading.py", line 152, in load_module_graph
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\modules\registry.py", line 163, in load
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\models.py", line 595, in _build_model
  File "C:\Program Files (x86)\Odoo 8.0-20150621\server\.\openerp\modules\registry.py", line 102, in __getitem__
KeyError: 'select.custom'

2 Answers 2

3

You using _inherit = 'select.custom' which is inheriting existing object so you have to make sure that object table is already loaded in memory.

Use _name instead _inherit to load that table.

Bests,

3
  • Thanks and however, I too have figured it out a while ago and now I updated my code as below but still getting the same error 1. removed the line _inherit = 'select.custom' from select_custom.py 2. removed the line <field name="inherit_id" ref="purchase.purchase_order_form"/> from select_custom_view.xml but still showing same error. Could you please check it out ?
    – Anis
    Commented Jul 28, 2015 at 15:30
  • Creating what kind of view, your view definition is wrong.
    – ifixthat
    Commented Jul 28, 2015 at 15:32
  • damn ! need to clear the basics first before playing around :( thanks though :)
    – Anis
    Commented Jul 28, 2015 at 15:39
1

Your error is related to file name. Everything is looks good apart from file name which you gave. You have to give file name __init__.py instead of __init.py

After this if your issue is remain same then check your inherited module. There might be some issue regarding inheritance.

Apart from that your .xml file looks good. No changes is needed in that.

Not the answer you're looking for? Browse other questions tagged or ask your own question.