Odoo Help


This community 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.


How to solve KeyError one2many field ?

Francisco Tobar
on 11/17/15, 11:41 AM 771 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 ??

Drees Far
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 ... :/

Drees Far
on 11/19/15, 9:02 AM

Drees Far

--Drees Far--
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 11/17/15, 11:41 AM
Seen: 771 times
Last updated: 11/19/15, 9:02 AM