Search code examples
odooodoo-13

OneToMany field in Odoo proper way to link two models


    raise UserError(_("No inverse field %r found for %r") % (self.inverse_name, self.comodel_name))
odoo.exceptions.UserError: ("No inverse field None found for 'res.sector'", '' )

I'm trying to create a new model and having problems linking it to another model.


Solution

  • You probably declared a One2many field like following:

    field_name = fields.One2many('res.sector')
    

    You need to specify the inverse name (mandatory), the name of a Many2one field declared in res.sector that reference the model where you declared the One2many field.