zoukankan      html  css  js  c++  java
  • openerp 中如何方便对搜索时间段

    以前为了方便的搜索时间区间,经常用wizard对方式,设置开始  结束时间,需要做大量对代码工作,

    今天看了search view对组成, 可以用2个filter_domain 来做, 这样用户需要输入2次时间, 然后选择对应对 “开始 结束”标签,就OK了。

    <field name="date_order" string="开始时间" filter_domain="[('date_order','>',self)]"/>
    <field name="date_order" string="结束时间" filter_domain="[('date_order','&lt;',self)]"/>

    例如,搜索本月 销售的明细

     <filter name="month_sale_product" string="本月已销售SKU"  domain="[('date_order','ilike',context_today().strftime('%%Y-%%m')),('product_id.type','=','product'),('state','not in',('draft','sent','cancel'))]"/>

    http://stackoverflow.com/questions/14537302/want-to-show-data-group-by-year-month-week-in-openerp-7

    <filter icon="terp-go-year" 
            string="Year"
            domain="[('date_from','&lt;=', time.strftime('%%Y-%%m-%%d')),'date_from','&gt;=',time.strftime('%%Y-01-01'))]"
            help="Current Year" 
            context="{'group_by':'date_from'}"/>
    
    <filter icon="terp-go-month" 
            string="Month"
            name="month"
            domain="[('date_from','&lt;=',(context_today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date_from','&gt;=',(context_today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
            help="Current Month" 
            context="{'group_by':'date_from'}"/>
    
    <filter icon="terp-go-week"
            string="Week"
            separator="1"
            name="week"
            domain="[('date_from','&lt;=', (context_today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%%Y-%%m-%%d')),('date_from','&gt;=',(context_today() - relativedelta(weeks=1, weekday=0)).strftime('%%Y-%%m-%%d'))]"
            help="Current Week" 
            context="{'group_by':'date_from'}"/>
    ~~~~~~~ 需要odoo 实施,二开,培训 等服务 QQ:190170444
  • 相关阅读:
    EMC、Pure和NetApp推新品,NAS闪存场景在哪里
    Tomcat 开启Gzip压缩
    win10+ubuntu双系统安装方案
    游戏中水的渲染技术系列一
    什么时候用到线程
    高并发和多线程
    angularJS双向绑定和依赖反转
    javascript ES6
    angularJS核心原理
    javascript限定输入textarea输入长度
  • 原文地址:https://www.cnblogs.com/alangwansui/p/3741936.html
Copyright © 2011-2022 走看看