Odoo Help


How to create Date from & Date to in search field ?

Debashis Das
on 5/24/13, 6:08 AM 4,545 views

How can I add "Date from" & "Date to" fields in Search view in Sales > Invoicing > All Uninvoiced Entries. The current code is as follows. How to change it. Please advice.

<search string="Search Analytic Lines">
                    <filter name="sales" string="Sales" domain="[('journal_id.type','=','sale')]" icon="terp-camera_test" help="Analytic Journal Items related to a sale journal."/>
                    <filter name="purchases" string="Purchases" domain="[('journal_id.type','=','purchase')]" icon="terp-purchase" help="Analytic Journal Items related to a purchase journal."/>
                    <filter name="others" string="Others" domain="[('journal_id.type','in',('cash','general','situation'))]" icon="terp-folder-orange"/>
                    <separator orientation="vertical"/>
                    <field name="date"/>
                    <field name="name"/>
                    <field name="account_id"/>
                    <field name="user_id">
                        <filter string="My Entries" domain="[('user_id','=',uid)]" icon="terp-personal"/>
                <group string="Group By..." expand="0">
                    <filter string="Account" context="{'group_by':'account_id'}" groups="base.group_extended" icon="terp-folder-green"/>
                    <filter string="Journal" context="{'group_by':'journal_id'}" icon="terp-folder-orange"/>
                    <filter string="User" context="{'group_by':'user_id'}" icon="terp-personal"/>
                    <separator orientation="vertical"/>
                    <filter string="Fin.Account" context="{'group_by':'general_account_id'}" icon="terp-folder-green"/>
                    <separator orientation="vertical"/>
                    <filter string="Product" context="{'group_by':'product_id'}" icon="terp-accessories-archiver"/>
On 8/16/13, 2:50 AM

Hi, You can add two fields in your .py :

'date_from':fields.function(lambda *a,**k:{}, method=True, type='date',string="Date from"),
'date_to':fields.function(lambda *a,**k:{}, method=True, type='date',string="Date to"),

and in search_view:

<field name="date_from" filter_domain="[('date_invoice','&gt;=',self)]"/>
<field name="date_to" filter_domain="[('date_invoice','&lt;=',self)]"/>

add domain as state in 'draft' or 'manual'

on 8/16/13, 2:54 AM

Many thanks!

Mihai Marius
on 1/14/14, 10:47 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 5/24/13, 6:08 AM
Seen: 4545 times
Last updated: 3/16/15, 8:10 AM