# Default value in a field depending on the view

**URL:** https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863
**Category:** Developer
**Created:** [December 16, 2021, 10:25am UTC](https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863 "2021-12-16T10:25:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aviejol](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/aviejol/32/1685_2.png) [@aviejol](https://discuss.tryton.org/u/aviejol)
#### Post date: [December 16, 2021, 10:25am UTC](https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863/1 "2021-12-16T10:25:09Z")

</div>

Hello, it is possible to know in which view a data model is open.

I need to put a default value in a field depending on which view the data is displayed. In a model with multiple views. Each view will have a domain to filter the data by that field.

Thank you

---

<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 16, 2021, 2:21pm UTC](https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863/2 "2021-12-16T14:21:55Z")

</div>

Not really but you can set a value in the context of the action that opens the view. This context will be used to call the default method of the field.  
But if you have domain constraint with `=` operator in such way that only one value is possible, the client will set the value automatically.

---

<div class="post-metadata">

### Author: ![aviejol](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/aviejol/32/1685_2.png) [@aviejol](https://discuss.tryton.org/u/aviejol)
#### Post date: [December 16, 2021, 3:12pm UTC](https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863/3 "2021-12-16T15:12:58Z")

</div>

That’s what I thought but I tried it and it didn’t work. I’ll try it again.

the domain would be in the call action or in sight.

---

<div class="post-metadata">

### Author: ![aviejol](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/aviejol/32/1685_2.png) [@aviejol](https://discuss.tryton.org/u/aviejol)
#### Post date: [December 16, 2021, 6:10pm UTC](https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863/4 "2021-12-16T18:10:09Z")

</div>

how could that value be in context?

---

<div class="post-metadata">

### Author: ![aviejol](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/aviejol/32/1685_2.png) [@aviejol](https://discuss.tryton.org/u/aviejol)
#### Post date: [December 16, 2021, 6:57pm UTC](https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863/5 "2021-12-16T18:57:36Z")

</div>

![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/8/8158abdf728af40855835eef91534bd6b2723adb.png)

---

<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: [January 15, 2022, 6:57pm UTC](https://discuss.tryton.org/t/default-value-in-a-field-depending-on-the-view/4863/6 "2022-01-15T18:57:58Z")

</div>

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