Search code examples
xmlodooodoo-9odoo-view

how to show archived task in many2many tree view on another model in Odoo9?


I'm trying to show the archived tasks (active = False) beside of the active tasks on many2many field view (Project Management Module) on Odoo9.

Ok, for a moment i just trying to show the archived tasks (active = False) only, so i've tried this code on my form view xml:

<field name="task_ids" widget="one2many_list" mode="tree" domain="[('active', '=', False)]"/>

OR

<field name="task_ids" widget="one2many_list" mode="tree" context="{'active_test': False,}"/>

But, still not working. The field 'task_ids' is still showing only the active tasks.


Solution

  • Odoo 9.0

    Here you will have to override the field. Change the domain of your field in a python file in your module.

    task_ids = fields.Many2many(
            domain=['|', ('active', '=', False), ('active', '=', True)])
    

    Trying to use active_test on Many2many won't work.

    Plus, note that [('active', 'in', [True, False])] won't work either. Because, whene the automatic active test is made, it will check if ('active', '=', False) is present. If not, it adds ('active', '=', True) to filter all archived items by default.