This question has been flagged
1 Reply
12521 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>
Avatar
Discard
Best Answer

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)]"/>
Avatar
Discard

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

Many thanks!