0

I’m trying to model a one-to-one relationship between two models in Odoo.

My approach was to use a Many2one + One2many, but on the form view Odoo always displays the One2many field as a list instead of a single form.

What I need
Model A has exactly zero or one related Model B record.
Model B has exactly zero or one related Model A record.
On the form view of a Model A record, the related Model B record should appear as a single form, not as a list.

Creating or editing Model A record should allow me to directly create or edit the related single Model B record inline. By Inline, I don't mean an inline list, it should be an inline form of the single record.

Model A

class ModelA(models.Model):
    _name = 'model.a'

    b_ids = fields.One2many('model.b', 'a_id')

Model B

class ModelB(models.Model):
    _name = 'model.b'

    a_id = fields.Many2one('model.a', unique=True)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.