Odoo中本日、本月、上月過濾器實現方法

Odoo中本日、本月、上月過濾器實現方法
<filter string="今日訂單" name="today" invisible="0" domain="[('date','=', current_date)]"/>
<filter string="本月訂單" name="month" invisible="0" domain="[('date','>=', time.strftime('%Y-%m-01')),('date','<', (context_today() + relativedelta(months=1)).strftime('%Y-%m-01') ) ]"/>
<filter string="上月訂單" name="month2" invisible="0" domain="[('date','<', time.strftime('%Y-%m-01')),('date','>=', (context_today() - relativedelta(months=1)).strftime('%Y-%m-01') ) ]"/>
<filter string="本年訂單" name="year" invisible="0" domain="[('date','<=', time.strftime('%Y-12-31')),('date','>=', time.strftime('%Y-01-01'))]"/>

【Odoo過濾器中可以使用的時間變量】

    datetime: datetime,
    context_today: context_today,
    time: time,
    relativedelta: relativedelta,
    current_date

原文地址:https://www.zhiyunerp.com/forum/erp-1/question/odoo-354

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章