Odoo Help

Welcome!

This community 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.

1

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

By
Debashis Das
on 5/24/13, 6:08 AM 3,270 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">
                <group>
                    <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"/>
                    </field>
                </group>
                <newline/>
                <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"/>
                </group>
            </search>
2
evon_dun
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'

evon_dun
on 8/16/13, 2:54 AM

Many thanks!

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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