filterodoo-14

Error when trying to add a filter to a view


I'm working on an Odoo 14 module but I ran into a problem when trying to add a filter to a view that allows viewing records for today. Here is the error i get

`Error: Control panel model extension failed to evaluate domain:/n{}`
    

Here is my code

<record id="models_cashouts_search" model="ir.ui.view">
        <field name="name">cash_in_out.request.search.view</field>
        <field name="model">cash_in_out.request</field>
        <field name="arch" type="xml">
            <search>
                <field name="appliquand_uid"/>
                <field name="amount"/>
                <field name="create_date" string="Date"/>
                <field name="acceptor_uid" />
                <filter string="Aujourd'hui" name="today" domain="[('create_date', '&gt;=', (context_today().strftime('%Y-%m-%d %H:%M:%S') - datetime.timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S')), ('create_date', '&lt;=', context_today().strftime('%Y-%m-%d %H:%M:%S'))]" />
            </search>
        </field>
</record>

Solution

  • You can try the below:

    <filter name="today" string="Today" domain="[('create_date', '=', context_today().strftime('%Y-%m-%d'))]" />