Odoo Help


KeyError: 'partner_id' when trying to inherit by delegation from res.partner

Nehemias Herrera
on 2/21/15, 7:32 PM 4,173 views

I am unsuccesfully trying to inherit by delegation from model res.parter the same way res.user does as it can be seen in https://github.com/odoo/odoo/blob/8.0/openerp/addons/base/res/res_users.py#L143-L145 , I am getting the following error from the following sample model

My model:

# -*- coding: utf-8 -*-
from openerp import fields
from openerp import models

class Example (models.Model):
    _name = 'example.prueba'
    _inherits = {
        'res.partner': 'partner_id',

    sample_field = fields.Char(string="Field")

The error:

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi


  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute

    application_iter = app(environ, start_response)

  File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 281, in app

    return self.app(e, s)

  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application

    return application_unproxied(environ, start_response)

  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied

    result = handler(environ, start_response)

  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1239, in __call__

    return self.dispatch(environ, start_response)

  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1213, in __call__

    return self.app(environ, start_wrapped)

  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__

    return self.app(environ, start_response)

  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1371, in dispatch

    ir_http = request.registry['ir.http']

  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 331, in registry

    return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None

  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 315, in get


  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 346, in new

    openerp.modules.load_modules(registry._db, force_demo, status, update_module)

  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 365, in load_modules


  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 174, in setup_models

    model._setup_fields(cr, SUPERUSER_ID, partial=partial)

  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 237, in wrapper

    return old_api(self, *args, **kwargs)

  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 332, in old_api

    result = method(recs, *args, **kwargs)

  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 2971, in _setup_fields


  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 411, in setup


  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 417, in _setup


  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 449, in _setup_related

    field = recs._fields[name]

KeyError: 'partner_id'

any help would be appreciated, thanks.



Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 2/21/15, 10:14 PM


you must had field partner_id in your code, like it is made in class res users.



Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 5 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 2/23/15, 2:09 AM

In inherits delegation, you define a dictinary that implies the object and the column name in current table.

from openerp import fields
from openerp import models

class Example (models.Model):
    _name = 'example.prueba'
    _inherits = {
        'res.partner': 'partner_id',

    sample_field = fields.Char(string="Field")
    partner_id = fields.Many2one('res.partner',
# Need to define the key defined at _inherits


Hi, no need to repeat the same answer I done one day before you this is the second time, see : https://www.odoo.com/forum/help-1/question/xpath-for-order-line-field-in-sale-order-view-75925#answer-75933 . thanks

Cyril Gaspard (GEM)
on 2/23/15, 6:29 PM

Your answer was pointed correctly but no sufficient explanation was available with it. So, i added an answer that is easier for Odoo forum newbies.

Atchuthan - Technical Consultant, Sodexis Inc
on 2/24/15, 12:02 AM

Check the datetime stamp of xpath question that have 2 answers: Mine(2/10/15, 3:58 PM) and Ivan(2/10/15, 4:06 PM). I think we both added an answer simultaneously.

Atchuthan - Technical Consultant, Sodexis Inc
on 2/24/15, 12:15 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/21/15, 7:32 PM
Seen: 4173 times
Last updated: 3/16/15, 8:10 AM