تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
27447 أدوات العرض

Helloooooooooooooooooooooooo there!

Admit that we are march 7th.

I want a filter who accepts only date of the current month and the last month.

So I want a filter who accepts date from february 1st to march 31th (but I won't have document dated after the march 7th).

Is my filter ok?

XML filter :

<filter string="Current and last months" name="currentandlastmonths" 
domain="[
('date','&gt;=',(context_today()-relativedelta(months=1)).strftime('%Y-%m-01')),
('date','&lt;',(context_today()+relativedelta(months=1)).strftime('%Y-%m-01'))

]" />


Edit #1

Interesting link to learn about this kind of filter. Many examples there :

http://odoobyriyasshon.blogspot.ca/2015/07/search-view-filters-in-odoo.html


الصورة الرمزية
إهمال

You have to be careful though, because the link you provided will not take timezone into account.

أفضل إجابة

Please follow below code :


A - <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'))]"/>

<filter string="Prev Month" name="prev_month" domain="[(‘create_date,'&gt;=',(context_today()-relativedelta(months=1)).strftime('%%Y-%%m-01')),(‘create_date','&lt;',time.strftime('%%Y-%%m-01'))]"/>
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
ديسمبر 22
3750
2
سبتمبر 19
14251
1
أغسطس 25
15
0
يوليو 25
889
1
مايو 25
1626