Using `context_model` window domain?

In Reporting date - passing date to search in list-view 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:

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 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" />

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”?

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

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

1 Like