Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
2573 Näkymät

add the “today” filter to a view in the pos session model. To view today's sessions only

Avatar
Hylkää
Paras vastaus

Hi,

   

Hi,
To add a "today" filter to a view in the POS session model in Odoo, you can use domain filtering in the XML definition of the view. 

   

<record id="view_pos_session_filter_today" model="ir.ui.view">

   

    <field name="name">pos.session.filter.today</field>

   

    <field name="model">pos.session</field>

   

    <field name="arch" type="xml">

   

        <search string="POS Sessions Today">

   

            <filter name="today" string="Today" domain="[('date_order', '>=', datetime.datetime.combine(datetime.date.today(), datetime.time.min)), ('date_order', '<=', datetime.datetime.combine(datetime.date.today(), datetime.time.max))]"/>

   

        </search>

   

    </field>

   

</record>

   


   


   

Make sure to replace "pos.session" with the actual model name if it's different. After adding this XML definition, you can apply the filter by selecting "POS Sessions Today" from the filters dropdown in the POS session view.


Hope it helps

Avatar
Hylkää
Tekijä

Thank you very much, does it also work in studio with odoo entreprises in saas?

Hi.
I copy and paste your filter domain but for use in crm.lead model with create_date field but i have an error:
Uncaught Promise > Failed to evaluate the domain: ["&", ("type", "=", "opportunity"), ("create_date", ">=", datetime.datetime.combine(datetime.date.today(), datetime.time.min))]. Cannot read properties of undefined (reading 'hour')

can you help me or maybe give some ideas?


I assume that this is checking today in UTC which might not be the same as in user's timezone.

In the XML you'd need to encode '<' and '>' characters using &lt; and &gt;, probably this is Gabriel's issue.

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
huhtik. 25
747
2
maalisk. 25
678
2
maalisk. 25
1196
1
helmik. 25
903
7
helmik. 25
1889