# Allow user to view and save a field, but not edit

**URL:** https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636
**Category:** User
**Created:** [September 18, 2021, 2:21pm UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636 "2021-09-18T14:21:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![locx](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/f04885/32.png) [@locx](https://discuss.tryton.org/u/locx)
#### Post date: [September 18, 2021, 2:21pm UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/1 "2021-09-18T14:21:14Z")

</div>

On the invoice form, suppose I don’t want a user to be able to change the field ‘Invoice Address’, which is populated automatically when the Party is selected.

To do that I disable write access for the field, but now, on saving the record, that field is not saved.

How can I allow the field to be viewed and saved, but not edited by a specific user?

---

<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: [September 18, 2021, 2:37pm UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/2 "2021-09-18T14:37:42Z")

</div>

Then you must set the value on the server side by the create and/or write methods.

---

<div class="post-metadata">

### Author: ![locx](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/f04885/32.png) [@locx](https://discuss.tryton.org/u/locx)
#### Post date: [September 19, 2021, 4:47pm UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/3 "2021-09-19T16:47:55Z")

</div>

Here’s what’s odd about this: if I disable write permission for the ‘Warehouse’ field in the Sale model, it still gets saved. But if I disable write permission for ‘Invoice Address’, it does not get saved. Why is this?

---

<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: [September 19, 2021, 10:45pm UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/4 "2021-09-19T22:45:28Z")

</div>

Because it is not the warehouse set by the client that is saved but the default warehouse value defined on the model. It just happens to be the same.  
The client does not sent to the server the value of the field it knows the user has not access right.

---

<div class="post-metadata">

### Author: ![locx](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/f04885/32.png) [@locx](https://discuss.tryton.org/u/locx)
#### Post date: [September 20, 2021, 9:27am UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/5 "2021-09-20T09:27:29Z")

</div>

> [@Allow user to view and save a field, but not edit](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/2):
>
> Then you must set the value on the server side by the create and/or write methods.

Could you please point to an example where something similar has been done before? I’m afraid I don’t follow exactly.

---

<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: [September 20, 2021, 9:32am UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/6 "2021-09-20T09:32:27Z")

</div>

I do not think Tryton relies anywhere on such design because normally if something is not editable by the user than there is no new information and we can compute it.

---

<div class="post-metadata">

### Author: ![locx](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/l/f04885/32.png) [@locx](https://discuss.tryton.org/u/locx)
#### Post date: [September 20, 2021, 9:35am UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/7 "2021-09-20T09:35:10Z")

</div>

> [@Allow user to view and save a field, but not edit](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/2):
>
> Then you must set the value on the server side by the create and/or write methods.

So I suppose you are asking to override the methods?

_Edit (add)_: Basically I don’t want the user to be able to change the ‘Invoice Address’ which is automatically added once a party is selected. And I want it to be saved when the user saves the record.

---

<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: [September 20, 2021, 10:38am UTC](https://discuss.tryton.org/t/allow-user-to-view-and-save-a-field-but-not-edit/4636/8 "2021-09-20T10:38:00Z")

</div>

I think the simpler is to add a validation check to ensure it is the address you want (or maybe better add a domain constraint on the address field such that only the right address can be selected).
