OpenERP (Odoo) Development Example search retrieves data for the last 3 months

Source: Internet
Author: User

Transferred from: http://www.chinamaker.net/

Search filtering for OpenERP (Odoo) Development examples: Retrieving data for the last 3 months
The key to solving this problem lies in the application of Relativedelta

The sample code is as follows:

1: <!--filter:last three months-->2: <filter icon="terp-personal"Name="Last_three_month"3:string="Last 3 Months"4:domain="[(' Date ', ' &lt;= ', time.strftime ('%%d/%%m/%%y ')),5: ('Date','&gt;=',6: ((Context_today () -7:relativedelta (months=3)). Strftime ('%%d/%%m/%%y')))8:]"/>

explanation :

    • Line 4th: time.strftime(‘%%d/%%m/%%Y‘) returns the current date; &lt;= is a less than sign, which can only be represented in XML. This line says, "before today."
    • 5th, 6, 7: context_today() It's another way to return the current date in OpenERP, minus relativedelta(months=3) three months ago. These three lines indicate "greater than three months ago", where the &gt;= greater than sign is in XML.
    • Together, "three months ago to today", or "last three months"

OpenERP (Odoo) Development Example search retrieves data for the last 3 months

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.