콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
1158 화면

In odoo 16 I have done a lot of dashboard and I need to set filter for periods from 1 Jan to 2 Feb. and  the periods is drop down and  I need to set specific date range  

아바타
취소
베스트 답변


Date Filter

아바타
취소
베스트 답변

Hii,

Option 1: Use Predefined Filters with Domain in XML Search View

You can add predefined filters with fixed date ranges in your search view XML like this:
<record id="view_your_model_search" model="ir.ui.view">

    <field name="name">your.model.search</field>

    <field name="model">your.model</field>

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

        <search>

            <!-- Existing filters -->


            <filter string="1 Jan to 2 Feb" name="period_jan_feb"

                domain="[

                    ('date_field', '>=', '2025-01-01'),

                    ('date_field', '<=', '2025-02-02')

                ]"/>


            <filter string="3 Feb to 31 Mar" name="period_feb_mar"

                domain="[

                    ('date_field', '>=', '2025-02-03'),

                    ('date_field', '<=', '2025-03-31')

                ]"/>

        </search>

    </field>

</record>

Replace 'date_field' with your actual date field name.

This will add a dropdown filter with these periods users can just click to filter.


Option 2: Use the Built-in Date Filters Widget

Odoo’s search views also support:

  • Date Range widget on date fields (users pick custom ranges),
  • Predefined time periods (like last month, this year) out of the box.

You can add a date filter on your date field to allow quick selection:
<filter string="Date" name="date_filter" domain="[]" context="{'group_by':'date_field'}"

    help="Filter by date">

    <field name="date_field" filter_domain="[]"/>

</filter>

Users will get a calendar popup and predefined options (week, month, year, custom).
i hope it is use full

아바타
취소
관련 게시물 답글 화면 활동
1
1월 25
18014
1
1월 20
3986
1
12월 19
6428
1
12월 19
17326
3
4월 18
5203