如何在 2 个日期之间进行搜索视图?
How to make a search view between 2 dates?
我得到了一个模型 (Activity),上面有字段日期 ("date")。我想在我的模块上实现一个搜索视图,而不是查找 2 个日期之间的活动。
有人知道怎么做吗?我通过描述做了一个搜索视图,但不知道如何实现:
<record model="ir.ui.view" id="activity_search_view">
<field name="name">activity.search</field>
<field name="model">proyectosge.activity</field>
<field name="arch" type="xml">
<search>
<field name="description"/>
</search>
</field>
</record>
静态和相对日期
如果日期始终相同,您可以像这样创建过滤器
<filter string="This Year"
name="thisyear"
domain="['|', ('date', '=', False), '&',('date','<=', time.strftime('%%Y-12-31')),('date','>=',time.strftime('%%Y-01-01'))]"
help="Journal invoices with period in current year" />
所以,看看域,更多示例(今年,本月,今天,静态日期):
domain="[('date','<=', time.strftime('%%Y-12-31')),('date','>=',time.strftime('%%Y-01-01'))]"
domain="[('date','<=', time.strftime('%Y-%m-%d')),('date','>=',time.strftime('%Y-%m-01'))]"
domain="[('date','<=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('date','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"
domain="[('date','<=', time.strftime('2020-12-31')),('date','>=',time.strftime('2000-01-01'))]"
动态日期
如果它们不是静态的,您必须在高级搜索中添加这两个条件。您也可以将过滤器添加到收藏夹
Note: Keep in mind that you have to press the "Apply" to add each condition in the advanced search to use an "and" operator. Don´t press the button "Add a condition" because you are going to use an "or" operator
我得到了一个模型 (Activity),上面有字段日期 ("date")。我想在我的模块上实现一个搜索视图,而不是查找 2 个日期之间的活动。
有人知道怎么做吗?我通过描述做了一个搜索视图,但不知道如何实现:
<record model="ir.ui.view" id="activity_search_view">
<field name="name">activity.search</field>
<field name="model">proyectosge.activity</field>
<field name="arch" type="xml">
<search>
<field name="description"/>
</search>
</field>
</record>
静态和相对日期
如果日期始终相同,您可以像这样创建过滤器
<filter string="This Year"
name="thisyear"
domain="['|', ('date', '=', False), '&',('date','<=', time.strftime('%%Y-12-31')),('date','>=',time.strftime('%%Y-01-01'))]"
help="Journal invoices with period in current year" />
所以,看看域,更多示例(今年,本月,今天,静态日期):
domain="[('date','<=', time.strftime('%%Y-12-31')),('date','>=',time.strftime('%%Y-01-01'))]"
domain="[('date','<=', time.strftime('%Y-%m-%d')),('date','>=',time.strftime('%Y-%m-01'))]"
domain="[('date','<=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('date','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]"
domain="[('date','<=', time.strftime('2020-12-31')),('date','>=',time.strftime('2000-01-01'))]"
动态日期
如果它们不是静态的,您必须在高级搜索中添加这两个条件。您也可以将过滤器添加到收藏夹
Note: Keep in mind that you have to press the "Apply" to add each condition in the advanced search to use an "and" operator. Don´t press the button "Add a condition" because you are going to use an "or" operator