# Default expand the tree in the client

**URL:** https://discuss.tryton.org/t/default-expand-the-tree-in-the-client/1513
**Category:** Developer
**Created:** [June 28, 2019, 12:42pm UTC](https://discuss.tryton.org/t/default-expand-the-tree-in-the-client/1513 "2019-06-28T12:42:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [June 28, 2019, 12:42pm UTC](https://discuss.tryton.org/t/default-expand-the-tree-in-the-client/1513/1 "2019-06-28T12:42:51Z")

</div>

I have a form with some fields, and below that a list of children. This list of children is displayed as a tree. When I open a record (switch the view to form-mode), the tree is default fully collapsed to 1 level. But now I want the tree to be fully expanded when I open the form, so I don’t need to expand the children myself. The level of depth is max. 3.

It there an XML option which defines this?

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [June 28, 2019, 12:53pm UTC](https://discuss.tryton.org/t/default-expand-the-tree-in-the-client/1513/2 "2019-06-28T12:53:36Z")

</div>

I found `tree_state` and added it to the `<tree tree_state="1">.....</tree>`. It seems that this is user specific.  
Hopefully there is also something which is working globally and just expand the tree.

---

<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: [June 28, 2019, 2:44pm UTC](https://discuss.tryton.org/t/default-expand-the-tree-in-the-client/1513/3 "2019-06-28T14:44:02Z")

</div>

No there is not option to always expand a tree because a tree can have an infinite number of level if it is recursive for example.  
But you can extend the `get` method of `ir.ui.view_tree_state` to return an expanded state for your model.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [June 28, 2019, 3:15pm UTC](https://discuss.tryton.org/t/default-expand-the-tree-in-the-client/1513/4 "2019-06-28T15:15:23Z")

</div>

Thanks! For me, adding the tree\_state to the XML is the most easy solution and when clearly communicated with the users it should be enough for now. First let them work with it for some months if they still complain, we can extend the `get` method 😄

---

<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: [July 28, 2019, 3:15pm UTC](https://discuss.tryton.org/t/default-expand-the-tree-in-the-client/1513/5 "2019-07-28T15:15:31Z")

</div>

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