Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1642 Lượt xem

Hello,

I want to add a filter to the sales app that shows the sales orders so far in the current month (updated automatically). That way I can add it to a spreadsheet to make a custom dashboard. 

However I have not been able to create a filter that filters the creation date for the current month automatically.


Can someone help?

Thanks 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi 

Try this code in search view of sale order 

   

<filter string="Current Month" name="current_month"

        domain="[('create_date','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')),

        ('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"/>


Regards

Ảnh đại diện
Huỷ bỏ
Tác giả

Can you send a screenshot of where to put this code?

Thanks!

Câu trả lời hay nhất

If you don't want to edit the view, (in Odoo 17+) in the filter pop-up you can input the following

(you need developer mode on)

The code is

[("date_order", ">", datetime.datetime.combine(context_today(), datetime.time(6, 0, 0)).strftime("%Y-%m-01 %H:%M:%S"))]
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 23
1871
1
thg 2 24
1218
1
thg 12 23
4666
1
thg 5 25
1984
1
thg 4 25
3043