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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 1 25
|
17861 | ||
|
1
thg 1 20
|
3845 | ||
|
1
thg 12 19
|
6272 | ||
|
1
thg 12 19
|
17200 | ||
|
3
thg 4 18
|
5100 |