Odoo Help


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.


Add a filter to an existing tree view

on 2/2/15, 9:10 AM 1,884 views

Hello, I have Odoo 8 and I am developing a module.

I want to add a new filter button in Accounting->Invoices, with this domain:

domain="[('date_invoice','<=',((context_today()-datetime.timedelta(days=10)).strftime('%Y-%m-%d'))), ('state', '=', 'open')]"

How must I define the .xml view to add the filter with this domain? I was searching and trying but I don't found the way. Thanks!


Akhil P Sivan

--Akhil P Sivan--
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 2/2/15, 11:00 AM

Hi Jose,

You try like this:

       <record id="view_account_invoice_filter_inherited" model="ir.ui.view">
                <field name="name">view.account.invoice.filter</field>
                <field name="model">account.invoice</field>
                <field name="type">search</field>
                <field name="inherit_id" ref="account.view_account_invoice_filter"/>
                <field name="arch" type="xml">
                        <xpath expr="/search/filter[1]" position="after">
                               <filter name="open" string="Open" domain="[('date_invoice','&lt;=',((context_today()-datetime.timedelta(days=10)).strftime('%Y-%m-%d'))), ('state', '=', 'open')]" help="Invoices Open"/>

Add this record to the xml file of your custom module. If your domain condition is correct, then I think this should work for you. Hope this helps you.

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

1 follower(s)


Asked: 2/2/15, 9:10 AM
Seen: 1884 times
Last updated: 3/16/15, 8:10 AM