Hi,
I have a form view with 3 pages in the notebook. I need to have 3 models in the same form, but the ODOO only allows one. Is there any way around this?
Best regards
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I have a form view with 3 pages in the notebook. I need to have 3 models in the same form, but the ODOO only allows one. Is there any way around this?
Best regards
Hello Pedro,
For this, you can use _inherits concepts of odoo.
For Ex :-
class MainModel(models.Model):
_name = 'main.model'
_inherits = {'model.a': 'a_id', 'model.b': 'b_id', 'model.c':'c_id'}
a_id = fields.Many2one('model.a', 'A')
b_id = fields.Many2one('model.b', 'B')
c_id = fields.Many2one('model.c', 'C')
# another fields which you want to display
class ModelA(models.Model):
_name = 'model.a'
a_name = fields.Char('A Name')
# another fields for A model
class ModelB(models.Model):
_name = 'model.b'
b_name = fields.Char('B Name')
# another fields for A model
class ModelC(models.Model):
_name = 'model.c'
c_name = fields.Char('C Name')
# another fields for A model
In Xml :-
<record id="new_view" model="ir.ui.view">
<field name="name">main.model</field>
<field name="model">main.model</field>
<field name="arch" type="xml">
<form>
<sheet>
<notebook>
<page string="A">
<field name="a_name"/>
</page>
<page string="B">
<field name="b_name"/>
</page>
<page string="C">
<field name="c_name"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
Hope it works for you.
Thanks,
@Jignesh Mehta, you have change the "has a" relation in the "is a" relation , it will create a huge burden on db schema as the data size grow in MOdel A,B and C , this is not right
Hello @Prakash, This is the only way to do that for @Pedro's situation.
@Prakash Sharma in odoo we have a facility of _inherits so we can use relation to use data like as example given by @Jignesh Mehta so we can use this way , and from my point of view @Jignesh Mehta is right. Thanx
Hi @Jigness Mehta,
thanks for the answer. I already have this structure, the problem is I want to put a form in each page of the notebook. I tried to do this:
<field name="payment_ids"> <form string="Payments"> <field name="name"/> </form> </field>
However, this form only appears when I click "Add an item" in the list that appears by default, because the field "payment_ids" is a One2Many.
see my updated ans. It will help you.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Dec 24
|
41 | ||
|
1
Mar 24
|
839 | ||
|
1
Jun 23
|
10731 | ||
|
0
Jan 23
|
1567 | ||
|
3
Feb 21
|
24811 |