Hi!
How can I render a Many2one field as subform ?
Model Diagram
https://imgur.com/RHyw3RT
Model Foo
from odoo import models, fields, api
class Foo(models.Model):
_name = 'foobar.foo'
name = fields.Char()
age = fields.Integer()
length = fields.Float(digits=(5, 2))
question = fields.Selection(selection=[('yes', 'Yes'), ('no', 'No')], string='Question')
gender = fields.Selection(selection=[('male', 'Male'), ('female', 'Female'), ('other', 'Other')], string='Gender')
Model Bar
from odoo import models, fields, api
class Bar(models.Model):
_name = 'foobar.bar'
name = fields.Char()
foo_1_id = fields.Many2one('foobar.foo')
foo_2_id = fields.Many2one('foobar.foo')
foo_3_id = fields.Many2one('foobar.foo')
View Form Foo
<record id="view_foobar_foo_view_form" model="ir.ui.view">
<field name="name">Foo Form</field>
<field name="model">foobar.foo</field>
<field name="arch" type="xml">
<form string="Foo Form">
<sheet>
<field name="id" invisible="1"/>
<group name="group_data" col="1">
<group col="6">
<field name="name"/>
<field name="age"/>
<field name="length"/>
<field name="question"/>
<field name="gender"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
View Form Bar
<record id="view_foobar_bar_view_form" model="ir.ui.view">
<field name="name">Bar Form</field>
<field name="model">foobar.bar</field>
<field name="arch" type="xml">
<form string="Bar Form">
<sheet>
<field name="id" invisible="1"/>
<group name="group_data" col="1">
<group col="2">
<field name="name"/>
</group>
<group col="6">
<field name="foo_1_id"/>
<field name="foo_2_id"/>
<field name="foo_3_id"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
Actual view Many2one field widget
https://imgur.com/rJCpKbw
Expected view
https://imgur.com/LAw3lju
Thank you so much