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

I've created a filter for filter last month and last year of order it doesn't work correctly

<filter icon="terp-go-month" string="Last Year"
                         domain="[('date_order','&lt;=', (context_today()-relativedelta(day=31,months=12,years=1)).strftime('%%Y-%%m-%%d')),
                         ('date_order','&gt;=',(context_today()-relativedelta(day=1,months=1,years=1)).strftime('%%Y-%%m-%%d'))]"
                         help="last year"/>

<filter icon="terp-go-month" string="Last Month"
                         domain="[('date_order','&lt;=', (context_today()-relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),
                         ('date_order','&gt;=',(context_today()-relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
                         help="last month"/>

and I create filter for month like this it works correctly

<filter icon="terp-go-month" string="Month"
                             name="month"
                             domain="[('date_order','&lt;=',
                             (context_today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),
                             ('date_order','&gt;=',
                             (context_today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
                             help="current month"/>

I dont know why? Thank for support

아바타
취소
베스트 답변

This is a correct way to filter the current month. Use it to create your own filter:

<filter string="Current Month" name="current_month" domain="[('data','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')), ('data','&gt;=',time.strftime('%%Y-%%m-01'))]"/>

This is an example of previous month:

<filter string="Prev Month" name="prev_month" domain="[('data','&gt;=',(context_today()-relativedelta(months=1)).strftime('%%Y-%%m-01')),('data','&lt;',time.strftime('%%Y-%%m-01'))]"/>
아바타
취소

The problem is, maybe, in another point

베스트 답변

This is an example of 'Last Year':

<filter string="Last Year" domain="[('reg_date','&gt;=',(context_today()-relativedelta(years=1)).strftime('%%Y-01-01')),('reg_date','&lt;=', time.strftime('%%Y-01-01'))]"/>


This is an example of 'Last Month':

<filter string="Last Month" domain="[('reg_date','&gt;=',(context_today()-relativedelta(months=1)).strftime('%%Y-%%m-01')),('reg_date','&lt;',time.strftime('%%Y-%%m-01'))]"/>


아바타
취소
관련 게시물 답글 화면 활동
3
4월 23
34445
1
1월 16
11409
0
3월 15
5112
1
4월 24
14315
3
3월 15
20765