# Lock Editable Tree based on States

**URL:** <https://discuss.tryton.org/t/lock-editable-tree-based-on-states/4405>\
**Category:** Developer\
**Created:** [July 12, 2021, 2:29am UTC](https://discuss.tryton.org/t/lock-editable-tree-based-on-states/4405 "2021-07-12T02:29:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![athelia](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/9fc29f/32.png) [@athelia](https://discuss.tryton.org/u/athelia)\
**Post date:** [July 12, 2021, 2:29am UTC](https://discuss.tryton.org/t/lock-editable-tree-based-on-states/4405/1 "2021-07-12T02:29:14Z")

</div>

Hi,

I’m trying to make a one2many editable tree readonly based on states but it doesn’t seem to work in Tryton-SAO 5.0.34. It seems that the issue doesn’t appear in 5.6 but I can’t seem to find any patch for 5.0 for this issue.

May I know how can I resolve this?

Thanks

---

<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 12, 2021, 6:23am UTC](https://discuss.tryton.org/t/lock-editable-tree-based-on-states/4405/2 "2021-07-12T06:23:16Z")

</div>

> [@athelia](#):
>
> but it doesn’t seem to work

What is not working?

---

<div class="post-metadata">

**Author:** ![athelia](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/9fc29f/32.png) [@athelia](https://discuss.tryton.org/u/athelia)\
**Post date:** [July 12, 2021, 6:36am UTC](https://discuss.tryton.org/t/lock-editable-tree-based-on-states/4405/3 "2021-07-12T06:36:29Z")

</div>

![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/7/7548dae7014d654448fda599219641b9a5735108.png)

Hi @ced,  
For example in the image above, which I tested on [demo5.0.tryton.org](http://demo5.0.tryton.org)  
the one2many tree is still editable when the record state is done.

---

<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 12, 2021, 7:02am UTC](https://discuss.tryton.org/t/lock-editable-tree-based-on-states/4405/4 "2021-07-12T07:02:36Z")

</div>

This is the expected behavior if you set the `readonly` only on the `One2Many`. The records inside the `One2Many` must also set their field as `readonly` in your case.  
But as it is the inventory, the states are already set on the fields. So it seems to be a bug in sao 5.0 which was solved later. It is probably a refactoring otherwise the fix would have been backported.

Even if we still maintain 5.0 series, it is always better to work on the latest because 5.0 maintenance is just best effort and it is a lot reduced over time.
