Odoo Help


How to solve KeyError one2many field ?

Francisco Tobar
on 11/17/15, 11:41 AM 1,947 views

Hello, I have a module with one2many field, which installed without any problems. But when I update the module generates a KeyError for that field .

invf = env[self.comodel_name]._fields[self.inverse_name]

KeyError: 'ubicacion'

The code is:

class res_partner(models.Model):
_inherit = 'res.partner'
movimientos_dispenser = fields.One2many('movimientos','ubicacion',domain=[('fecha_retiro','=',False)])

class Movimientos(models.Model):
_name = 'movimientos'
name = fields.Many2one('dispenser',domain=[('disponible','=',True)] , ondelete='restrict', string='Codigo de dispenser', required=True)
ubicacion = fields.Many2one ('res.partner',domain=[('customer','=',True)], string="Ubicacion", required=True, ondelete="restrict")

Thank you for your help.

hello my friend, did you get a solution or you still need help ??

Vale Trood
on 11/18/15, 3:53 AM

Hello, thanks for your interest. I resolved the problem correcting the dependences of the modules.

Regards ,Francisco.

De: Drees Far <far.drees@gmail.com>
Enviado: miércoles, 18 de noviembre de 2015 05:53 a.m.
Para: Francisco Tobar
Asunto: Re: How to solve KeyError one2many field ?

hello my friend, did you get a solution or you still need help ??

Drees Far
Sent by Odoo S.A. using Odoo
Open Source ERP and CRM | Odoo
>From ERP to CRM, eCommerce and CMS. Download Odoo or use it in the cloud. Grow Your Business.
about Forum Post How to solve KeyError one2many field ?
Francisco Tobar
on 11/19/15, 8:58 AM

happy for hearing that my friend :) but i though you will upvote my answer ... :/

Vale Trood
on 11/19/15, 9:02 AM

Vale Trood

--Vale Trood--

| 5 2 7
Tunis, France
--Vale Trood--

Vale Trood
On 11/17/15, 11:49 AM

Hello my friend here is an example of two classes with Many2one and One2Many feilds:

class author(models.Model):

_name = 'mylibrary.author'

_rec_name = 'lastname'

firstname = fields.Char('FirstName', required=True)

lastname = fields.Char('LastName', required=True)

book_ids = fields.One2many('mylibrary.book','author_id','Books')

class book(models.Model):

_name = 'mylibrary.book'

title = fields.Char('Title', required=True)

genre = fields.Char('Genre', required=True)

author_id = fields.Many2one('mylibrary.author','Author',ondelete='cascade')

Here is a link you may follow to understand and get the answer.


Best Regards.

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: 11/17/15, 11:41 AM
Seen: 1947 times
Last updated: 11/19/15, 9:02 AM