# How to create several nested forms in a module?

**URL:** https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366
**Category:** Developer
**Created:** [July 22, 2023, 3:38pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366 "2023-07-22T15:38:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![lb1975](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lb1975](https://discuss.tryton.org/u/lb1975)
#### Post date: [July 22, 2023, 3:38pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/1 "2023-07-22T15:38:05Z")

</div>

Hi Tryton community,

I’m wondering if it’s possible to create nested forms, i will try to explain with a simple example:  
Module World, form world with a list of continent  
form continent with a list of country  
form country with a list of town  
I don’t need a nested menu too but I need that db tables are created with the correct primary/secondary keys to allow the links between the forms.

Maybe someone knows a module made like that ?

Thanks in advance.  
Laurent

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 22, 2023, 4:50pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/2 "2023-07-22T16:50:50Z")

</div>

I guess you are looking for [`One2Many` fields](https://docs.tryton.org/projects/server/en/latest/ref/fields.html#one2many).

---

<div class="post-metadata">

### Author: ![lb1975](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lb1975](https://discuss.tryton.org/u/lb1975)
#### Post date: [July 22, 2023, 5:30pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/3 "2023-07-22T17:30:21Z")

</div>

Yes I use a One2Many field inside world.py to link continent.py  
Can I use again a One2Many field inside continent.py to link country.py and a One2Many field inside country.py to link town.py ?  
Is there a limitation concerning the number of nested One2Many field ?  
At the end, db side we should have table\_world with key\_world, table\_continent with key\_continent and key\_world, table\_country with key\_country and key\_continent, table\_town with key\_town and key\_country, isn’t it ?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 22, 2023, 5:35pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/4 "2023-07-22T17:35:09Z")

</div>

> [@lb1975](#):
>
> Is there a limitation concerning the number of nested One2Many field ?

No

> [@lb1975](#):
>
> At the end, db side we should have table\_world with key\_world, table\_continent with key\_continent and key\_world, table\_country with key\_country and key\_continent, table\_town with key\_town and key\_country, isn’t it ?

There will be a table per `ModelSQL` classes.

---

<div class="post-metadata">

### Author: ![lb1975](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lb1975](https://discuss.tryton.org/u/lb1975)
#### Post date: [July 22, 2023, 8:25pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/5 "2023-07-22T20:25:10Z")

</div>

Ok thank you very much it works.

---

<div class="post-metadata">

### Author: ![udono](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/udono/32/2114_2.png) [@udono](https://discuss.tryton.org/u/udono)
#### Post date: [July 27, 2023, 1:59pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/6 "2023-07-27T13:59:43Z")

</div>

> [@lb1975](#):
>
> I’m wondering if it’s possible to create nested forms

Maybe you also speak of a nested representation of the data in a tree or graph.

[You can create a list view with a tree structure.](https://demo6.8.tryton.org/#demo6.8/model/account.account.type;domain=%5B%5B%22statement%22%2C%22%3D%22%2C%22balance%22%5D%2C%5B%22OR%22%2C%5B%22parent%22%2C%22%3D%22%2Cnull%5D%2C%5B%22parent.statement%22%2C%22!%3D%22%2C%22balance%22%5D%2C%5B%22parent.statement%22%2C%22%3D%22%2Cnull%5D%5D%5D&context=%7B%22cumulate%22%3Atrue%2C%22context_model%22%3A%22account.balance_sheet.comparison.context%22%2C%22company%22%3A1%2C%22comparison%22%3Afalse%2C%22date%22%3A%7B%22 __class__ %22%3A%22date%22%2C%22year%22%3A2023%2C%22month%22%3A7%2C%22day%22%3A27%7D%2C%22date_cmp%22%3Anull%2C%22posted%22%3Afalse%7D&context_model=account.balance_sheet.comparison.context&name=%22Financial%20%2F%20Reporting%20%2F%20Balance%20Sheet%22&views=%5B213%5D)

AFAIK it is also possible to use different underlying models in one graph, only the represented fields in the graph must be named the same.

But AFAIK it is not possible to show such a graph inside a form view, as [you can see in the product categories representation](https://demo6.8.tryton.org/#demo6.8/model/product.template/3;name=%22Products%22&views=%5B308%2C307%5D) on product form view.

---

<div class="post-metadata">

### Author: ![lb1975](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lb1975](https://discuss.tryton.org/u/lb1975)
#### Post date: [July 27, 2023, 4:44pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/7 "2023-07-27T16:44:30Z")

</div>

No it was really a list in a form when you switch this list to the form you see a new list and again you switch to a form which contains a list.  
List view with tree structure is a nice feature, thanks for the info 😉

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [August 26, 2023, 4:45pm UTC](https://discuss.tryton.org/t/how-to-create-several-nested-forms-in-a-module/6366/8 "2023-08-26T16:45:23Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
