Domain for one2many not working Odoo

javatar picture javatar · Jul 22, 2015 · Viewed 9.8k times · Source

In my module I want to filter one2many records based on current date. This is my xml code

<field name="record_ids" domain="[('end_date', '&gt;', cur_date)]">
    <tree string="records_tree">
        <field name="record_id"/>
        <field name="record"/>
        <field name="start_date"/>
        <field name="end_date"/>
    </tree>
</field>

cur_date is a functional field I added to get current date.

My problem is records are not filtered in the view. Also it doesn't show any error message

Answer

user4728618 picture user4728618 · Jul 29, 2015

you are define the domain in the XML file . so this domain it's not work .

please define in the .py file .

For Example :

'record_ids':fields.one2many('model_name','model_id','Record',domain=[('end_date', '>=', 'cur_date')])

here the cur_date you need to define one function field which show the current date.

So Please check this may be it's help full to you :).