# Dynamic model access permissions

**URL:** https://discuss.tryton.org/t/dynamic-model-access-permissions/6763
**Category:** Developer
**Created:** [December 8, 2023, 3:35pm UTC](https://discuss.tryton.org/t/dynamic-model-access-permissions/6763 "2023-12-08T15:35:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bell](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/c67d28/32.png) [@bell](https://discuss.tryton.org/u/bell)
#### Post date: [December 8, 2023, 3:35pm UTC](https://discuss.tryton.org/t/dynamic-model-access-permissions/6763/1 "2023-12-08T15:35:51Z")

</div>

Is it possible to make Model readonly based on some condition?  
The best way would be to have dynamic model access permissions like this:

```auto
<record model="ir.model.access" id="...">
    ...
    <field name="perm_write" eval="Eval(...)" pyson="1"/>
    ...
</record>

```

Model Access disables menu items New/Copy (Ctrl+N/Shift+Ctrl+D), Record Rules don’t.  
In this case users will see their permissions and won’t even try to add/copy records.

---

<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: [December 11, 2023, 10:05am UTC](https://discuss.tryton.org/t/dynamic-model-access-permissions/6763/2 "2023-12-11T10:05:38Z")

</div>

> [@bell](#):
>
> Is it possible to make Model readonly based on some condition?

Yes using [record rules](https://docs.tryton.org/projects/server/en/latest/topics/access_rights.html#record-rule).

> [@bell](#):
>
> The best way would be to have dynamic model access permissions like this:

And what would be the context of the evaluation? If it is the record than it is the same as record rule.

> [@bell](#):
>
> Model Access disables menu items New/Copy (Ctrl+N/Shift+Ctrl+D), Record Rules don’t.

Record rules are enforced on client side since [Manage deletable and writable state from ir.rule on the client side (#9357) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9357).

---

<div class="post-metadata">

### Author: ![bell](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/c67d28/32.png) [@bell](https://discuss.tryton.org/u/bell)
#### Post date: [December 11, 2023, 3:13pm UTC](https://discuss.tryton.org/t/dynamic-model-access-permissions/6763/3 "2023-12-11T15:13:06Z")

</div>

We need to disable the “New/Copy” menu items if the “closed” period is selected. Can this be done using record rules?

---

<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: [December 11, 2023, 6:01pm UTC](https://discuss.tryton.org/t/dynamic-model-access-permissions/6763/4 "2023-12-11T18:01:50Z")

</div>

“New” and “Copy” are linked to the creation access and we can not know which content will be created. So the client can not be proactive for this.
