# Using \`context\_model\` window domain?

**URL:** https://discuss.tryton.org/t/using-context-model-window-domain/6927
**Category:** Developer
**Created:** [January 29, 2024, 6:16pm UTC](https://discuss.tryton.org/t/using-context-model-window-domain/6927 "2024-01-29T18:16:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)
#### Post date: [January 29, 2024, 6:16pm UTC](https://discuss.tryton.org/t/using-context-model-window-domain/6927/1 "2024-01-29T18:16:28Z")

</div>

In [Reporting date - passing date to search in list-view](https://discuss.tryton.org/t/reporting-date-passing-date-to-search-in-list-view/6897) I learned hot to use `context_model` to filer what is show in a list-view.

Now I try to use the `context_model` in a window domain, like this:

 ![grafik](https://discuss-cdn.tryton.org/uploads/default/original/2X/e/e204b584c71f2243dbe486edfd6fd0fffe88b8e7.png)

This view shall show several “window domain”, where some depend on the date (date within or outside some period of the record) while others don’t depend on the date (here: depend on the state).

My non-working code:

```
    <record model="ir.action.act_window" id="act_members_form">
        <field name="name">Show current Members</field>
        <field name="res_model">association.member</field>
        <field name="context_model">association.member.context</field>
    </record>

    <record model="ir.action.act_window.domain" id="act_members_list_current">
        <field name="name">Current</field>
        <field name="sequence" eval="30" />
        <field name="domain"
	   eval="[('join_date' ,'!=', None),
		 ('join_date', '&lt;=', Eval('date', Date())),
		 ['OR', ('leave_date', '=', None),
		        ('leave_date', '&gt;=', Eval('date', Date()))]]"
	   pyson="1" />
        <field name="count" eval="True" />
        <field name="act_window" ref="act_members_form" />
    </record>

```

In the “window domain”, `date` is undefined, which will make the `Eval(('date', Date())` return today’s date. (I tried different expressions, this is why I know `date` is undefined.)

How can I use the `date` value from the `context_domain` in the “window domain”?

---

<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: [January 29, 2024, 6:39pm UTC](https://discuss.tryton.org/t/using-context-model-window-domain/6927/2 "2024-01-29T18:39:41Z")

</div>

window domains like action domain are only evaluated once at creation of the window.

---

<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: [January 30, 2024, 10:22am UTC](https://discuss.tryton.org/t/using-context-model-window-domain/6927/3 "2024-01-30T10:22:23Z")

</div>

Indeed the fact that `domain` and `tab_domain` are evaluated only once comes from a time where there was no `context_model` so the evaluation would always be the same.  
But I think there is nothing that would prevent to reevaluate them after each search: [Re-evaluate domains with screen context when refreshing (#12973) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/12973)
