This question has been flagged
1 Reply
16323 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!

Avatar
Discard
Best Answer

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"/>
                        </xpath>
                </field>
        </record>

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.

Avatar
Discard