This question has been flagged
1 Reply
10474 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.

Avatar
Discard

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

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 ?

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

Best Answer

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.

http://lolierp.blogspot.com/2014/11/odoo-8-creation-dun-module-simple.html

Best Regards.

Avatar
Discard