コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
1593 ビュー

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 

アバター
破棄
最善の回答

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

アバター
破棄
著作者

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

Thanks!

最善の回答

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"))]
アバター
破棄
関連投稿 返信 ビュー 活動
2
9月 23
1817
1
2月 24
1189
1
12月 23
4631
1
5月 25
1922
1
4月 25
2975