PURPOSE:
To filter records that match multiple conditions at the same time and present them in a tree view.
The context:
By understanding how to use action window domains, in a module we named “incident” has records that are categorized into States, Processes, User.
-
The states are: Request, Draft, Waiting, Assigned, Running,
-
In the “res.user” model we added the field “process” which assigns a Tryton user.
Currently, the window domains correctly filter requests by status. (only one condition)
DIFFICULTY:
The following example code runs without generating errors, however, when including several conditions we are unsuccessful, it does not do the expected filtering of the domain by the conditions.
ENVIRONMENT:
- OS: Ubuntu 20.04.1 LTS
- Python: 3.8.5
- Trytond: 5.8.7
- Tryton: 5.8.7
- Module: 5.8
- Postgresql: 12.5
EXAMPLE CODE:
Code to filter one condition
Code to filter by state:
<record model="ir.action.act_window.domain" id="act_incident_requested_list_domain_discarded">
<field name="name">Discarded</field>
<field name="sequence" eval="10"/>
<field name="domain" eval="[('state', '=', 'discarded')]" pyson="1"/>
<field name="count" eval="True"/>
<field name="act_window" ref="act_incident_requested_list"/>
</record>
Code to filter several conditions
Filtering by status and process of the active user.
<record model="ir.action.act_window.domain" id="act_incident_requested_list_domain_discarded">
<field name="name">Discarded</field>
<field name="sequence" eval="10"/>
<field name="domain" eval="[('state', '=', 'discarded'), ('process', '=', Eval('user', {}).get('process', None))]" pyson="1"/>
<field name="count" eval="True"/>
<field name="act_window" ref="act_incident_requested_list"/>
</record>
We appreciate your help !